AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Log event , global variables troubles (https://forums.alliedmods.net/showthread.php?t=85865)

mihaiveress 02-17-2009 06:17

Log event , global variables troubles
 
Hello i need some help to make some ideas about scripting regarding log events and global variables and the way they are mainained
sorry if i don't express myself write but I am at the begining ( only 3 posts :D )


first of all here is the entire source from the plugin i want to modify :D
http://files.filefront.com/xPaw+Antirusher...;/fileinfo.html

i want to do the followings
1. In the plugin it is set that a certain type of punishment is applied to the rushers depending on the cvar set by amx_antirusher_action
i want to make this punishment dinamic and to set the punishment by itself dependending on how many times the player has rushed
i thought of making a global array g_playerp[32] and here to set the number of rushes made
i know that if i declare [b] new g_playerp[32]=0 all of the fields will be set to 0 ( please corect me if I am wrong)
so..when you get to the punishment part ( M_Antirusher Punishments it is highlighted by comments :D ) i thought that this could be enough to change from the whole punishplayer function
PHP Code:

punishPlayer(id) {
    new 
action 0
    
new name[32]
    
get_user_name(id,name,31)
    
action get_cvar_num("amx_antirusher_action")
    if (
get_cvar_num("amx_antirusher_immunity") == 1) {
        if (
get_user_flags(id)&ADMIN_IMMUNITY) {
            
action 0
        
}
    }
    
    new 
players[32], ok=0num
    get_players
(players,num)
    new 
i=1
    
if(action==0)  // if admin then it won't get into the loop just write to other admins
         
{
         
ok=1  
         
new name[32]
         
get_user_name(id,name,31)
         
server_cmd("amx_chat %L",LANG_SERVER,"AR_SRV_INFO"name)
         }
    while(
i<num&&ok==0)
        {
        if(
equali(players[i]==id))
           {
           
g_playerp[i]++
           
ok=1
           
}
        
i++   
        }
    
i-=1    
        
    
switch (g_playerp[i]) {
        case 
0:{
            new 
name[32]
            
get_user_name(id,name,31)
            
server_cmd("amx_chat %L",LANG_SERVER,"AR_SRV_INFO"name)
            }
        case 
1:    server_cmd("amx_slap #%d %d",id,40)            
        case 
2user_silentkill(id)
        case 
3kickPlayer(id)
        case 
4banPlayer(id)
    }
    
client_print(idprint_chat"You crossed rush border! Dont break a rules! Say /rules")
    
log_amx("%s has passed rush borders",name)


so could this be right?
i want to determine the punishments by the authID, i also think that after banPlayer(id) i shoudl initialize to 0 the g_playerp[i] according to that authID because it leaves the server and it changes :D


another thing that i want to do is "play" with the events
what i mean by that is to count the number of wins that CTs and T have and to set a task that checks if the difference between the CT and the T score is more then 10 ( 2 global variables g_ctwin-g_twin>=10 ) and only then change the cvar amx_antirusher to 1 ( at de_ maps )
so when that happens some cvars get changed
- amx_antirusher = 1
- amx_antirusher_time = 120 ( the roundtime cvar of the server is set for 2 minutes => no rush at all, strange rules I know :D )
i found something for the event logging but don't know if it's enough to count
in the plugin_init()
Code:

register_logevent("t_round_end",2, "3=Terrorists_Win");
register_logevent("ct_round_end",2, "3=CTs_Win");

and after that
PHP Code:

public t_round_end()
{
    
g_twin+=1
}

public 
ct_round_end()
{
    
g_ctwin+=1


if i write like this will their value be increased?


another thing is to "delay" the punishments.
for example a player crosses the rush limit and it gets slaped or warned beeing the first time
i want the next punishment wouldn't be apllied as soon as he gets back rushing ( i mean a delay of half of minute or something like that)
i think that a solution might be to change the g_playerp array type and make it a double one like g_playerp[32][2] where g_playerp[i][1] shows the value of the rushes and g_playerp[i][2] will show the last time he was punished ( putting the value in by get_round_time )

for now these are my questions and i will try to find some answers in the morning by myself if noone helps me.... ( i hope it won't be the case :D )

thank you in advance :D


All times are GMT -4. The time now is 16:53.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.