Raised This Month: $ Target: $400
 0% 

storing authID of players in global array


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
mihaiveress
Member
Join Date: Jan 2009
Location: Tirgu-Mures , Romania
Old 02-26-2009 , 08:01   storing authID of players in global array
Reply With Quote #1

hello i have a problem storing the players authID in an array and I don't know why

i thought of 2 solutions but i don't know where to put this code
Code:
g_punish[g_num][0]=id
	g_punish[g_num][1]=0
	g_punish[g_num][2]=get_timeleft()
	g_num+=1
should i put it in client_connect or client putinserver because etherway it doesn't seem to work

Last edited by mihaiveress; 02-26-2009 at 12:36.
mihaiveress is offline
Send a message via Yahoo to mihaiveress Send a message via Skype™ to mihaiveress
stupok
Veteran Member
Join Date: Feb 2006
Old 02-26-2009 , 12:58   Re: storing authID of players in global array
Reply With Quote #2

I'm not sure what you're trying to do. You should show your code and explain your goal.
__________________
stupok is offline
hleV
Veteran Member
Join Date: Mar 2007
Location: Lithuania
Old 02-26-2009 , 13:11   Re: storing authID of players in global array
Reply With Quote #3

Didn't really understand what you're doing but maybe this is what you need (only an example).
Code:
// Max players server can hold #define MAX_PLAYERS 32   // Max IDs that can be stored in an array + 1 // Max characters of SteamID new g_SteamID[MAX_PLAYERS + 1][32];   // Client is authorized, store his ID in g_SteamID public client_authorized(Client) {         // Local array which will hold the SteamID of Client         new SteamID[32];         // Get user SteamID and store it in SteamID array         get_user_authid(Client, SteamID, 31);           // Store data from SteamID array to g_SteamID global array         formatex(g_SteamID[Client], 31, SteamID); }
__________________
hleV is offline
mihaiveress
Member
Join Date: Jan 2009
Location: Tirgu-Mures , Romania
Old 02-26-2009 , 13:13   Re: storing authID of players in global array
Reply With Quote #4

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 
i,ok=0
    
for(i=0;i<g_num&&(!ok);i++)
      {
      if(
g_punish[i][0]==id)
         {
         
ok=1
         
if(!actiong_punish[i][1]+=1
         
}
      }

    }
    
    
server_cmd("amx_say g_num=%d  i=%d ok=%d p=%d id=%d",g_num,i,ok,g_punish[i][1],g_punish[i][0])  
    new 
timp=get_timeleft()    
    if((
g_punish[i][2]-timp) > )
        {
        switch(
g_punish[i][0])
        {
        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_slap #%d %d",name,5)            
            }
        case 
1
            {
            
server_cmd("amx_slap #%d %d",id,40)         
            }
        case 
2server_cmd("amx_slay2 #%d 1",id
        case 
3banPlayer(id)
        default:{
            new 
name[32]
            
get_user_name(id,name,31)
            
server_cmd("amx_chat %L:p",LANG_SERVER,"AR_SRV_INFO"name)
            
server_cmd("amx_chat g_punish[%d]=%d timp=%d",i,g_punish[i][0],timp)
            }
        }
        
        }
    
g_punish[i][2]=timp  
    
    
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
        
}        
    }

it all comes down to this
i need to keep in the array g_punish[i][] the authID of the players

i thought something like this
Code:
public client_putinserver(id){ 		
	new arg[1] 			
	arg[0]=id			
	g_punish[g_num][0]=id
	g_punish[g_num][1]=0
	g_punish[g_num][2]=get_timeleft()
	g_num+=1	
	if (map_cors_pre && get_cvar_num("amx_antirusher"))
		set_task(45.0,"informclient",TASK_INFO+id,arg,1) 
		
}
mihaiveress is offline
Send a message via Yahoo to mihaiveress Send a message via Skype™ to mihaiveress
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 02-26-2009 , 15:30   Re: storing authID of players in global array
Reply With Quote #5

First off, you have an odd number of braces. You end your function half way through the posted code.

g_num will blow up (i.e. go to infinity)

I think you should use something like this:
PHP Code:
new g_punish[33][2]
public 
client_putinserver(id)
{
 
g_punish[id][0] = // Number of Punishes?
 
g_punish[id][1] = get_timeleft() // Timeleft at last punish

And if your playerpunish function is supposed to be for a single player (which seems to be because of punishPlayer(id)) you should use g_punish[id][#] when getting or setting the info.


Also, no where in your code do you use "authID". authID will be something like: STEAM_0:1:132334.


Also,

PHP Code:
server_cmd("amx_slap #%d %d",name,5)
server_cmd("amx_slap #%d %d",id,40
are used incorrectly.

Use one of:
PHP Code:
server_cmd("amx_slap %s %d",name,5)
server_cmd("amx_slap #%d %d",userid,40
where userid = get_user_userid(id)


EDIT:
Ok, I came up with something. You can check it out in the attached file. Basically with my code: if a player is punished 4 times within 5 minutes they get banned. If they don't get banned in that 5 minutes punishes and the time is reset.
__________________

Last edited by fysiks; 04-01-2009 at 16:14.
fysiks is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 02-26-2009 , 23:18   Re: storing authID of players in global array
Reply With Quote #6

PHP Code:
new g_szAuthID[33][33];

public 
client_authorized(id)
{
    
get_user_authidid g_szAuthID[id] , 32 );

__________________
Bugsy is offline
mihaiveress
Member
Join Date: Jan 2009
Location: Tirgu-Mures , Romania
Old 02-27-2009 , 03:49   Re: storing authID of players in global array
Reply With Quote #7

Quote:
Originally Posted by fysiks View Post
First off, you have an odd number of braces. You end your function half way through the posted code.

g_num will blow up (i.e. go to infinity)

I think you should use something like this:
PHP Code:
new g_punish[33][2]
public 
client_putinserver(id)
{
 
g_punish[id][0] = // Number of Punishes?
 
g_punish[id][1] = get_timeleft() // Timeleft at last punish

And if your playerpunish function is supposed to be for a single player (which seems to be because of punishPlayer(id)) you should use g_punish[id][#] when getting or setting the info.


Also, no where in your code do you use "authID". authID will be something like: STEAM_0:1:132334.


Also,

PHP Code:
server_cmd("amx_slap #%d %d",name,5)
server_cmd("amx_slap #%d %d",id,40
are used incorrectly.

Use one of:
PHP Code:
server_cmd("amx_slap %s %d",name,5)
server_cmd("amx_slap #%d %d",userid,40
where userid = get_user_userid(id)


EDIT:
Ok, I came up with something. You can check it out in the attached file. Basically with my code: if a player is punished 4 times within 5 minutes they get banned. If they don't get banned in that 5 minutes punishes and the time is reset.
normally this should do the trick but it isn't working
i mean that from some reasons the g_punish[id][0] ( nr of punishments ) goes crazy and is still rising
i think that it could be done by this
PHP Code:
public checkOrigin() {             // tu sprawdza czy rashujesz
    
    
if (round_start<1) return
    if (
get_gametime() > g_time)
    {
        
free_the_world()
        return
    }
    
    new 
players[32], num,tt_num,ct_num
    get_players
(players,num)
    
    for(new 
i=0;i<num;i++)
    {
        if(
is_user_alive(players[i]))
        {
            if(
cs_get_user_team(players[i])==CS_TEAM_Ttt_num++
            else if(
cs_get_user_team(players[i])==CS_TEAM_CTct_num++
        }
    }
    
    if (
tt_num<MIN_PLAYERS)
    {
        
free_the_world()
        return
    }
    if (
ct_num<MIN_PLAYERS)
    {
        
free_the_world()
        return
    }
    
    
    
get_players(players,num)
    
set_task(TEST_TIME"checkOrigin"TASK_LOOP)
    for(new 
0numi++) 
    {
        if(
is_user_alive(players[i]))
        {
            if((
equal(g_team,"T")&&(cs_get_user_team(players[i])==CS_TEAM_T))||(equal(g_team,"CT")&&(cs_get_user_team(players[i])==CS_TEAM_CT))||equal(g_team,"XX"))
            {    
                
get_user_origin(players[i],g_origin)
                if ((
map_cors_origin[0] < g_origin[0] < map_cors_origin[1]) && (map_cors_origin[2] < g_origin[1] < map_cors_origin[3]) && (map_cors_origin[4] < g_origin[2] < map_cors_origin[5]) ||
                    (
map_cors_origin[6] < g_origin[0] < map_cors_origin[7]) && (map_cors_origin[8] < g_origin[1] < map_cors_origin[9]) && (map_cors_origin[10] < g_origin[2] < map_cors_origin[11]) ||
                    (
map_cors_origin[12] < g_origin[0] < map_cors_origin[13]) && (map_cors_origin[14] < g_origin[1] < map_cors_origin[15]) && (map_cors_origin[16] < g_origin[2] < map_cors_origin[17]) ||
                    (
map_cors_origin[18] < g_origin[0] < map_cors_origin[19]) && (map_cors_origin[20] < g_origin[1] < map_cors_origin[21]) && (map_cors_origin[22] < g_origin[2] < map_cors_origin[23]) ||
                    (
map_cors_origin[24] < g_origin[0] < map_cors_origin[25]) && (map_cors_origin[26] < g_origin[1] < map_cors_origin[27]) && (map_cors_origin[28] < g_origin[2] < map_cors_origin[29]) ||
                    (
map_cors_origin[30] < g_origin[0] < map_cors_origin[31]) && (map_cors_origin[32] < g_origin[1] < map_cors_origin[33]) && (map_cors_origin[34] < g_origin[2] < map_cors_origin[35])){
                    
punishPlayer(players[i])
                    
raszer[players[i]]=1
                
}
                else{
                    
free_the_man(players[i])
                }
            }
        }
    }

any ideas?
thanks for all of the help
mihaiveress is offline
Send a message via Yahoo to mihaiveress Send a message via Skype™ to mihaiveress
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 02-27-2009 , 05:00   Re: storing authID of players in global array
Reply With Quote #8

Quote:
Originally Posted by mihaiveress View Post
normally this should do the trick but it isn't working
i mean that from some reasons the g_punish[id][0] ( nr of punishments ) goes crazy and is still rising
The number of punishes shouldn't go above 4 unless the person does not get kicked when they are "banned" by your banPlayer(id) function. Or if you use it anywhere else in your plugin it could be screwed up there.

I have a clue as to what the rest of the plugin is so I can't help you .
__________________
fysiks is offline
mihaiveress
Member
Join Date: Jan 2009
Location: Tirgu-Mures , Romania
Old 02-27-2009 , 05:14   Re: storing authID of players in global array
Reply With Quote #9

i've managed to solve the problem, minor syntax problems and it is good now
i still have to test something and if it won't work i will be back

thanks for the help guys
mihaiveress is offline
Send a message via Yahoo to mihaiveress Send a message via Skype™ to mihaiveress
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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