Jump to content

Nachz

Nachz

Member Since 09 Mar 2015
OFFLINE Last Active Mar 26 2019 04:51 PM
-----

#17656 Need help with a lua script.

Posted by Nachz on 15 March 2015 - 05:42 PM

Thanks for the cvar, I really forgot this one.

 

Also I'm working on something else and the lua module don't want to load so I guess there is a problem with one of these function:

function et_Obituary(victim,killer,meansOfDeath)
      getkiller(victim,killer)
     	 
end

function getkiller(victimID,killerID)
   local hpkiller = et.gentity_get(killerID,"ps.stats",0)
   local name = et.gentity_get(killerID,"pers.netname")
   et.trap_SendServerCommand(victimID,"chat \"^7 "..name.." was at ^1"..hpkiller.." ^7HP when he killed you !\"")
   -- et.trap_SendConsoleCommand( et.EXEC_APPEND, "readconfig\n" )
   -- Pretty sure you don't need readconfig in this situation
   end
end

Thanks ! :D

 

Edit: Right after I posted the code I saw my error ^^ Fixed.




#17646 Need help with a lua script.

Posted by Nachz on 14 March 2015 - 02:47 PM

The new getXP fonction you gave me, works pretty well.

 

And I added this to my setskills function:

local gamestate = tonumber( et.trap_Cvar_Get('gamestate') )
   if gamestate == 0 then
   et.G_AddSkillPoints(playerID, 0, 500)
   et.G_AddSkillPoints(playerID, 1, 500)
   et.G_AddSkillPoints(playerID, 2, 500)	
   et.G_AddSkillPoints(playerID, 3, 500)	
   et.G_AddSkillPoints(playerID, 4, 500)	
   et.G_AddSkillPoints(playerID, 5, 500)	
   et.G_AddSkillPoints(playerID, 6, 500)
   et.G_AddSkillPoints(playerID, 1, 500)

And the good gamestate number was 0, because 1 is for warmup and 0 is for when the game is started.

 

Thanks a lot, my problem is fixed ! :D




#17589 Need help with a lua script.

Posted by Nachz on 09 March 2015 - 04:50 PM

Thanks for the fast answer, I will try it ;)

 

Edit: It worked, thanks you :D

 

Also to you know how to force the client to downlaod a .pk3 files in the etmain folder. The sv_pure only force the client to download pk3 files in the silent folder.

 

Thanks you again




#17586 Need help with a lua script.

Posted by Nachz on 09 March 2015 - 03:55 PM

Hi all, I'm working on a lua script that would give xp to new player under 1000xp. So they would have all skills. But I can't make it done... I tried 2 ways and both didn't worked well.

 

My lua is based on a other script between.

 

So I have been using this code for when the player spawn:

function et_ClientSpawn(clientNum, revived, teamChange, restoreHealth)
   local valXP = getXP(clientNum)
   if valXP < noexp then    
      setexp(clientNum)
   end
end

The value of noexp is 1000.

 

This is the first thing I tried (fonction setexp):

function setexp(playerID)
   local name = et.gentity_get(playerID,"pers.netname")
   local silentguid = et.gentity_get(playerID,"sess.guid")
   if isBot(playerID) or noGuid(playerID) then return end
      et.trap_SendServerCommand(-1,"chat \"^nCongratulations ^7"..name.."^n, ^nyou have ^nbeen ^nEXP! \"")
      et.trap_SendConsoleCommand( et.EXEC_APPEND, "givexp "..silentguid.." SOLD 500 \n" )
      et.trap_SendConsoleCommand( et.EXEC_APPEND, "givexp "..silentguid.." MED 500 \n" )
      et.trap_SendConsoleCommand( et.EXEC_APPEND, "givexp "..silentguid.." ENG 500 \n" )
      et.trap_SendConsoleCommand( et.EXEC_APPEND, "givexp "..silentguid.." FOPS 500 \n" )
      et.trap_SendConsoleCommand( et.EXEC_APPEND, "givexp "..silentguid.." COV 500 \n" )
      et.trap_SendConsoleCommand( et.EXEC_APPEND, "givexp "..silentguid.." LIGHT 500 \n" )
      et.trap_SendConsoleCommand( et.EXEC_APPEND, "givexp "..silentguid.." BATTLE 500 \n" )
      et.trap_SendConsoleCommand( et.EXEC_APPEND, "readconfig\n" )
end

But I realized that the command givexp use the silent ID when I'm using the Silent GUID because I didn't find any function that allow to get the silent ID. Maybe something that would only take the 8 last characters of the silent GUID could give the Silent ID, but I don't know how. (So I didn't got xp, I only seen the message)

 

so then I tried this using the G_AddSkillPoints...

function setskill(playerID)
   local name = et.gentity_get(playerID,"pers.netname")
   if isBot(playerID) or noGuid(playerID) then return end
      et.G_AddSkillPoints("..playerID..", 0, 500)
      et.G_AddSkillPoints("..playerID..", 1, 500)
      et.G_AddSkillPoints("..playerID..", 2, 500)	
      et.G_AddSkillPoints("..playerID..", 3, 500)	
      et.G_AddSkillPoints("..playerID..", 4, 500)	
      et.G_AddSkillPoints("..playerID..", 5, 500)	
      et.G_AddSkillPoints("..playerID..", 6, 500)
      et.G_AddSkillPoints("..playerID..", 1, 500)		  
      et.trap_SendServerCommand(-1,"chat \"^nCongratulations ^7"..name.."^n, ^nyou have ^nbeen ^nEXP! Welcome to MC ! \"")
	  et.trap_SendConsoleCommand( et.EXEC_APPEND, "readconfig\n" )
      
end

I think there are something missing, because the lua can get load when I type "/lua_status" I can see it.

 

Thanks for you help

 

Nachz