selfkill in battle


(OCdrone) #1

i’m trying to make a lua-script for selfkilling in battle. My objective is to find a way to make sure that people can’t sk in battle within 5 secs when being shot. I triend to make the lua script work, but i still a beginner in it. This is what i have:

function et_ClientCommand(client, command)
et.gentity_get(hitclient)
et.gentity_get(time)
if hitClient == qtrue then
if time <= 5000 then
if string.lower(command) == “kill” then
et.trap_SendServerCommand( client, "cp "^1Sorry, no selfkill in battle.
“” )
return 1
else
return 0
end
end
end
end

I have gotten al the commands from the sourcecode and i though they would work, but they don’t:(. Can someone help me get this right?


(SCDS_reyalP) #2

http://wolfwiki.anime.net/index.php/Lua_Mod_API

Among other things, you aren’t using et.gentity_get correctly. You must pass an entity number and field name (and array index if the field you are querying is an array)

The value of the field is returned.

Only field names listed here http://wolfwiki.anime.net/index.php/Fieldname are valid.


(variable) = et.gentity_get ( entnum, Fieldname ,arrayindex )

    Gets the value of Fieldname from entity entnum out of the g_entity struct. For NULL entities or clients, nil is returned.
    arrayindex is used to specify which element of an array entity field to get. It is required when accessing array type fields. Entity field array indexes start at 0. 



(OCdrone) #3

So if i get this right instead of et.gentity_get(hitclient) i should write:
hitclient = et.gentity_get(client, takedamage)
and for et.gentity_get(time) i should use:
time = et.gentity_get(client, s.time)


(SCDS_reyalP) #4

The second paramenter is the name of the field. So you would use


time = et.gentity_get(client, "s.time")

Of course, you have to look at the game code and find the fields that give you the information you need. I’m pretty sure s.time isn’t going to do what you want.


(McSteve) #5

Old thread revival 4tw.

Example here (check noinfightsk.lua).