anti prone :-)

Discussions about ET modding (sdk code, player/weapon modeling)

Moderators: Forum moderators, developers

User avatar
Luk4ward
Posts: 236
Joined: Sun Jul 30, 2006 1:55 pm
Location: Poland
Contact:

Post 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)
wolFTeam.pl
crazyfrag
Posts: 105
Joined: Fri Oct 01, 2004 1:17 pm

Post 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 :D and it worked :) now i 've made it a bit better :D
User avatar
Luk4ward
Posts: 236
Joined: Sun Jul 30, 2006 1:55 pm
Location: Poland
Contact:

Post 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...
wolFTeam.pl
crazyfrag
Posts: 105
Joined: Fri Oct 01, 2004 1:17 pm

Post 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
User avatar
Luk4ward
Posts: 236
Joined: Sun Jul 30, 2006 1:55 pm
Location: Poland
Contact:

Post 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 :/
wolFTeam.pl
User avatar
X-DOS
Posts: 19
Joined: Sat May 17, 2008 8:41 pm
Location: United World
Contact:

Post 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 :)
crazyfrag
Posts: 105
Joined: Fri Oct 01, 2004 1:17 pm

Post by crazyfrag »

and what can i do with this :O (im not that expert in lua coding :O )
User avatar
X-DOS
Posts: 19
Joined: Sat May 17, 2008 8:41 pm
Location: United World
Contact:

Post 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:

Code: Select all

#define EF_PRONE     0x00080000
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
crazyfrag
Posts: 105
Joined: Fri Oct 01, 2004 1:17 pm

Post by crazyfrag »

may u code a complete function for this? ty :)
User avatar
X-DOS
Posts: 19
Joined: Sat May 17, 2008 8:41 pm
Location: United World
Contact:

Post by X-DOS »

crazyfrag wrote:may u code a complete function for this? ty :)
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.
Last edited by X-DOS on Wed Mar 18, 2009 10:52 am, edited 1 time in total.
crazyfrag
Posts: 105
Joined: Fri Oct 01, 2004 1:17 pm

Post 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
Post Reply