AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   command not working (https://forums.alliedmods.net/showthread.php?t=221211)

Jhob94 07-19-2013 09:26

command not working
 
Hi
I tried made command for one thing but istn working...
amx_testcmd "Steam Id"

Then it should add steam id in one file, it just add ^n

code:
PHP Code:

public cmd_add_costum_ban(idlevelcid
{
    if(
cmd_access(idlevelcid2))
    {
        new 
new_steam_id[35]
        
read_argv(1new_steam_id34)
        
formatex(new_steam_id34"^n%s"new_steam_id)
        
        new 
File fopen(path"wt")
    
        
fprintf(Filenew_steam_id)
        
fclose(File)
        
        new 
players[32], num
        get_players
(playersnum)
        
        if(
num)
        {
            new 
user players[num]
            new 
steamid[35]
            
get_user_authid(usersteamid34)
            
            if(
equal(new_steam_idsteamid))
                
// code
        
}
    }



YamiKaitou 07-19-2013 09:32

Re: command not working
 
Use format

Jhob94 07-19-2013 09:32

Re: command not working
 
ok i gonna try
thanks

EDIT:
now just shows "STEAM_0" xD

fysiks 07-20-2013 03:53

Re: command not working
 
Quote:

Originally Posted by Jhob94 (Post 1994372)
now just shows "STEAM_0" xD

That happens when you don't use quotes.

ConnorMcLeod 07-20-2013 05:43

Re: command not working
 
If you input "^n" in steamid string, then you can't try to compare to connected players steamids, won't work.
Also fprintf allow formatting, use it.
Your get_players usage is not correct, you have to loop the array.
Also you could add to get_players flags c and h so you don't collect bots and you don't collect hltvs

PHP Code:

public cmd_add_costum_ban(idlevelcid
{
    if(
cmd_access(idlevelcid2))
    {
        new 
new_steam_id[32]
        
read_argv(1new_steam_idcharsmax(new_steam_id))

        new 
File fopen(path"wt")

        
fprintf(Filenew_steam_id)
        
fprintf(File"^n^"%s^""new_steam_id);
        
fclose(File)

        new 
players[32], numsteamid[32], user
        get_players
(playersnum"ch")
        for(--
numnum>=0num--)
        {
            
user players[num]
            
get_user_authid(usersteamidcharsmax(steamid))

            if(
equal(new_steam_idsteamid))
            {
                
// code



                
break // we have a match, don't continue the loop for nothing
            
}
        }
    }



Jhob94 07-20-2013 08:17

Re: command not working
 
Thanks, works like a charm :)


All times are GMT -4. The time now is 06:31.

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