AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Get log events , global variables comparation (https://forums.alliedmods.net/showthread.php?t=85748)

mihaiveress 02-15-2009 11:30

Get log events , global variables comparation
 
Hello
I have a script from an antirush plugin and tried to modify something at it
now please tell where I did wrong.... i will show you what i want to do with what part of it
this is the part refering to the punishments
PHP Code:

punishPlayer(id) {
                
    new 
action 1
    action 
get_cvar_num("amx_antirusher_action")    
    if ((
get_cvar_num("amx_antirusher_immunity") == 1)&&(get_user_flags(id)&ADMIN_IMMUNITY)) {
        
action 0
    
}
    switch (
action) {
        case 
0:{
        new 
name[32]
        
get_user_name(id,name,31)
        
server_cmd("amx_chat %L",LANG_SERVER,"AR_SRV_INFO"name)
        }
        case 
1:    fm_fakedamage id"rashing"slap*1.0,16384)
        case 
2user_silentkill(id)
        case 
3kickPlayer(id)
        case 
4banPlayer(id)
        case 
5:{
            if(
speed_limit[id]==0){
                
speed_limit[id]=1
                fm_set_user_maxspeed
(id,(fm_get_user_maxspeed(id)/2.0));
            }
        }
        case 
6:{
            if(
flashed[id]==0){
                
flashed[id]=1
                set_task
(FLASH_TIME,"Flash",TASK_FLASH+id
            }
        }
        case 
7:{
            new 
Floatvelocity[3]
            new 
FloatDW //Długosc wektora
            
pev(id,pev_velocity,velocity)
            
DW=vector_length velocity )+0.0001
            velocity
[0]=(velocity[0]/DW)*(-500.0)
            
velocity[1]=(velocity[1]/DW)*(-500.0)
            if(
velocity[2]<0velocity[2]=velocity[2]*(-1.0)+15.0 //wyrzuca do gory
            
set_pev(id,pev_velocity,velocity)    
        }
        case 
8:{
            
rasher[id]=1
        
}
        case 
9:{
            
aim_on_me(id)
        }
        case 
10:{
            
ebay_time_to_pay(id)    // ogladalem filmik w flashu i to chyba przez to :p
        
}
        default:{
            new 
name[32]
            
get_user_name(id,name,31)
            
server_cmd("amx_chat %L:p",LANG_SERVER,"AR_SRV_INFO"name)
        }
    }
    if (
warn_control >(25/floatround(10.0*TEST_TIME))){    // jak dlugo siedzisz w granicy to ci pisze w czacie :p
    
client_print(idprint_chat"%L",LANG_PLAYER,"AR_RASH_WARN")
    
warn_control=0;}
    
warn_control+=1

    
if(get_cvar_num("amx_antirusher_sound")){
        if(
sounded[id]==0){
        new 
sound_mode get_cvar_num("amx_antirusher_sound_mode")
        
        if(
sound_mode==0client_cmd(id,"spk %s",actions[action])
        else 
client_cmd(0,"spk %s",actions[action])
        
sounded[id]=1
        
}        
    }


now what i want to do is to disable the punishment menu and make the punishments apply by themselves so this is what how it now looks :d

PHP Code:

punishPlayer(id) {
                
    new 
action 1
    action 
get_cvar_num("amx_antirusher_action")    
    if ((
get_cvar_num("amx_antirusher_immunity") == 1)&&(get_user_flags(id)&ADMIN_IMMUNITY)) {
        
action 0
    
}
    
    new 
players[33], ok=0num
    get_players
(players,num)
    new 
i=1
    
if(action==0ok=1
    
while(i<num&&ok==0)
        {
        if(
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)
            
server_cmd("amx_tsay %L",LANG_SERVER,"AR_SRV_INFO"name)
            }
        
//case 1:    fm_fakedamage ( id, "rashing", slap*1.0,16384)
        
case 1:    server_cmd("amx_slap #%d %d",id,40)
            
        case 
2user_silentkill(id)
        case 
3kickPlayer(id)
        case 
4banPlayer(id)
default:{
            new 
name[32]
            
get_user_name(id,name,31)
            
server_cmd("amx_chat %L:p",LANG_SERVER,"AR_SRV_INFO"name)
        }
    }
    if (
warn_control >(25/floatround(10.0*TEST_TIME))){    // jak dlugo siedzisz w granicy to ci pisze w czacie :p
    
client_print(idprint_chat"%L",LANG_PLAYER,"AR_RASH_WARN")
    
warn_control=0;}
    
warn_control+=1

    
if(get_cvar_num("amx_antirusher_sound")){
        if(
sounded[id]==0){
        new 
sound_mode get_cvar_num("amx_antirusher_sound_mode")
        
        if(
sound_mode==0client_cmd(id,"spk %s",actions[action])
        else 
client_cmd(0,"spk %s",actions[action])
        
sounded[id]=1
        
}        
    }


now this is what I've changed
at the begining of the code I initiated a global array called g_playerp[33]=0 to set all the values to 0
when you enter the part of the punishments you get the authID of the player by function call
after that you get all the players id and compare them , if they are the same the value for g_playerp equal to the player is increased by 1
depending on what the number is you get the pennalty associated

pls tell me if i wrote it right?



LE: when I modify g_playerp does it take global effect?
I managed to solve the problem but it still doesn't take the punishment increase although i pass through 2 no rush limits ( and not with admin :| )

LLE: done...i was comparing 2 strings as if they ware numeric values :D

sorry for the space occupied :D


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

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