Page 3 of 3
Posted: Fri Feb 13, 2009 1:32 pm
by Luk4ward
crazyfrag wrote:Luk4ward wrote:
if ( ((et.gentity_get(j, "s.eFlags")) == 524292) or ( (et.gentity_get(j, "s.eFlags")) == 1572868 ) ) then
this wont work cuz if u press console or fire or anything else while prone the bitflag gets to high ... and sometimes u start playing ur bitflag is 4 and sometimes ist 0 so i used greater than function ... cuz this is for a headshot server so i dont have the really high bitflags so its working without problems!
the loweset bitfalg for prone has to be 524288
ok then, but u have to exclude the bitflag of using console (its more than 50 000)
Posted: Fri Feb 13, 2009 2:03 pm
by crazyfrag
Luk4ward wrote:
ok then, but u have to exclude the bitflag of using console (its more than 50 000)
sure sure this was my first test
![Very Happy :D](./images/smilies/icon_biggrin.gif)
and it worked
![Smile :)](./images/smilies/icon_smile.gif)
now i 've made it a bit better
![Very Happy :D](./images/smilies/icon_biggrin.gif)
Posted: Fri Feb 27, 2009 9:00 am
by Luk4ward
I want to catch a vote. From what u r saying this code should works:
Code: Select all
for j = 0, maxclients-1 do
if (et.gentity_get(j, "s.eFlags")) == 16384 then
voted = true
et.G_LogPrint(string.format("client %d voted\n",j))
end
end
But it isnt hmm...
Posted: Fri Feb 27, 2009 12:54 pm
by crazyfrag
flags are bitflags
it has to be 16900 i think...
Code: Select all
active 4
console /talking 512 (limbo etc.)
voted 16384
_______________________________
= 16900
but if i think about it then i think u have a mistake in ur script.
just 4 example if u do notihng and vote ur bitflag is 16900 but if u sit on a tank and vote ur bitflag is 49668
Posted: Sat Feb 28, 2009 4:20 am
by Luk4ward
crazyfrag wrote:flags are bitflags
it has to be 16900 i think...
Code: Select all
active 4
console /talking 512 (limbo etc.)
voted 16384
_______________________________
= 16900
but if i think about it then i think u have a mistake in ur script.
just 4 example if u do notihng and vote ur bitflag is 16900 but if u sit on a tank and vote ur bitflag is 49668
I see, what a shit :/
Posted: Sat Feb 28, 2009 4:56 am
by X-DOS
How about a simple function to handle this
Code: Select all
function tobits( number )
-- bits array
local bits = { }
-- let's get some bits
while( number > 0 ) do
-- bit value (reversed)
table.insert( bits, math.mod( number, 2 ) )
-- divide
number = math.floor( number / 2 )
end
return bits
end
Array is reversed (of course we can solve it) - but it's better for us.
Now just get the bit value:
bits[1] is a first bit (1)
bits[2] is a second one (2)
bits[3] is a 3rd one (4)
bits[4] and a 4th one (8)
etc.
I haven't checket this, but should work :)
Posted: Sat Mar 07, 2009 3:49 am
by crazyfrag
and what can i do with this :O (im not that expert in lua coding :O )
Posted: Sat Mar 07, 2009 8:13 am
by X-DOS
crazyfrag wrote:and what can i do with this :O (im not that expert in lua coding :O )
Let's see, the flag for prone is:
In decimal it will be 524288 or 2^19
So, we are going to use this function for any number (for example 524292) to get binary code
Code: Select all
local binary = tobits( 524292 )
as a result we have array of bits
524292 = 524288 + 4
1st bit, 1 = 0
2nd bit, 2 = 0
3rd bit, 4 = 1
4th bit, 8 = 0
...
9th bit, 262144 = 0
20th bit, 524288 = 1
now we can just simple check 20th bit of this array (because tables in lua begins from 1)
Code: Select all
if binary[20] then
--do something, prone flag is set
else
--do something
end
btw, note that there is another flag
Code: Select all
#define EF_PRONE_MOVING 0x00100000 // player is prone and moving
Posted: Tue Mar 17, 2009 1:05 am
by crazyfrag
may u code a complete function for this? ty
![Smile :)](./images/smilies/icon_smile.gif)
Posted: Wed Mar 18, 2009 7:04 am
by X-DOS
crazyfrag wrote:may u code a complete function for this? ty
![Smile :)](./images/smilies/icon_smile.gif)
You have almost done it
Code: Select all
samplerate = 200
--
function tobits( number )
-- bits array
local bits = { }
-- let's get some bits
while( number > 0 ) do
-- bit value (reversed)
table.insert( bits, math.mod( number, 2 ) )
-- divide
number = math.floor( number / 2 )
end
return bits
end
function et_InitGame( levelTime, randomSeed, restart )
mclients = tonumber( et.trap_Cvar_Get( "sv_maxClients" ) ) --gets the maxclients
end
function et_RunFrame( levelTime )
if math.mod( levelTime, samplerate ) ~= 0 or tonumber( et.trap_Cvar_Get( "gamestate" ) ) ~= 0 then
return
end
-- for all clients
for i = 0, mclients -1 do
local bits = tobits( et.gentity_get( i, "s.eFlags" ) )
if bits[20] or bits[21] then
et.gentity_set( i, "health", -200 )
et.G_Sound( i, et.G_SoundIndex( "sound/player/hurt_barbwire.wav" ) )
et.trap_SendServerCommand( -1, "chat "".. et.gentity_get( i, "pers.netname" ) .." ^3proned and has been gibbed!\n"" )
end
end
end
I havn't tested it, but this will clear up how my function works and you should be able to code it by yourself.
Posted: Wed Mar 18, 2009 9:57 am
by crazyfrag
Code: Select all
samplerate = 200
--
function tobits( number )
-- bits array
local bits = { }
-- let's get some bits
while( number > 0 ) do
-- bit value (reversed)
table.insert( bits, math.mod( number, 2 ) )
-- divide
number = math.floor( number / 2 )
end
return bits
end
function et_InitGame( levelTime, randomSeed, restart )
mclients = tonumber( et.trap_Cvar_Get( "sv_maxClients" ) ) --gets the maxclients
end
function et_RunFrame( levelTime )
gamestate = tonumber(et.trap_Cvar_Get( "gamestate" ))
if math.mod( levelTime, samplerate ) ~= 0 or gamestate == 1 or gamestate == 2 then
return
end
-- for all clients
for i = 0, mclients -1 do
local bits = tobits( et.gentity_get( i, "s.eFlags" ) )
if bits[20] or bits[21] then
et.gentity_set( i, "health", -200 )
et.G_Sound( i, et.G_SoundIndex( "sound/player/hurt_barbwire.wav" ) )
et.trap_SendServerCommand( -1, "chat \"".. et.gentity_get( i, "pers.netname" ) .." ^3proned and has been gibbed!\n\"" )
end
end
end
works pretty nice i've editetd it there was a mistake with a ; and the gamestate