AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Problem on Writing file line (https://forums.alliedmods.net/showthread.php?t=315621)

SpirT 04-15-2019 13:14

Problem on Writing file line
 
Hey guys.
I developed a plugin with writes steamid, flags and immunity and the name of client as this way
"my_steam_id" "immunity:flags" //player_name

But the problem is that when I select the player name, it adds the flags, etc but does to other players with the steamid of the player i choosed. How can i solve this?

PHP Code:

...

            if(
StrEqual(choice"vip"))
            {
                
char path[512];
                
BuildPath(Path_SMpathsizeof(path), "configs/admins_simple.ini");
                if(
FileExists(path))
                {
                    
char steamid[32];
                    for (
int i 1<= MaxClientsi++)
                    {
                        
GetClientAuthId(iAuthId_Steam2steamidsizeof(steamid));
                        
char sDisplay[50];
                        
Format(sDisplaysizeof(sDisplay), " %N"i);
                        
Handle file OpenFile(path"a");
                        
WriteFileLine(file"");
                        
WriteFileLine(file"\n\"%s\" \"20:ao\" //%N"steamidi); 
                        
CloseHandle(file);
                        
PrintToChat(client"%s Concluido!"PLUGIN_TAG);
                    }
                }
            }

...

public 
int clients_handler(Menu cmenuMenuAction actionint clientint item

    
char sDisplay[50], sIdx[5];
    for (
int i 1<= MaxClientsi++) 
    { 
        if (
IsClientInGame(i) && !IsFakeClient(i)) 
        { 
            
IntToString(isIdxsizeof(sIdx)); 
            
Format(sDisplaysizeof(sDisplay), " %N"i); 
            
cmenu.AddItem(sIdxsDisplay);
            if(
action == MenuAction_Select)
            {
                
delete cmenu;
                
CreatePermsMenu().Display(clientMENU_TIME_FOREVER);
            }            
        } 
    } 


How can i solve this??

8guawong 04-16-2019 07:21

Re: Problem on Writing file line
 
Quote:

Originally Posted by SpirT (Post 2647673)
Hey guys.
I developed a plugin with writes steamid, flags and immunity and the name of client as this way
"my_steam_id" "immunity:flags" //player_name

But the problem is that when I select the player name, it adds the flags, etc but does to other players with the steamid of the player i choosed. How can i solve this?

PHP Code:

...

            if(
StrEqual(choice"vip"))
            {
                
char path[512];
                
BuildPath(Path_SMpathsizeof(path), "configs/admins_simple.ini");
                if(
FileExists(path))
                {
                    
char steamid[32];
                    for (
int i 1<= MaxClientsi++)
                    {
                        
GetClientAuthId(iAuthId_Steam2steamidsizeof(steamid));
                        
char sDisplay[50];
                        
Format(sDisplaysizeof(sDisplay), " %N"i);
                        
Handle file OpenFile(path"a");
                        
WriteFileLine(file"");
                        
WriteFileLine(file"\n\"%s\" \"20:ao\" //%N"steamidi); 
                        
CloseHandle(file);
                        
PrintToChat(client"%s Concluido!"PLUGIN_TAG);
                    }
                }
            }

...

public 
int clients_handler(Menu cmenuMenuAction actionint clientint item

    
char sDisplay[50], sIdx[5];
    for (
int i 1<= MaxClientsi++) 
    { 
        if (
IsClientInGame(i) && !IsFakeClient(i)) 
        { 
            
IntToString(isIdxsizeof(sIdx)); 
            
Format(sDisplaysizeof(sDisplay), " %N"i); 
            
cmenu.AddItem(sIdxsDisplay);
            if(
action == MenuAction_Select)
            {
                
delete cmenu;
                
CreatePermsMenu().Display(clientMENU_TIME_FOREVER);
            }            
        } 
    } 


How can i solve this??

did you check your error logs?
i'm pretty sure there will be errors since you didn't check if client is in game like in your other for loop

SpirT 04-16-2019 13:51

Re: Problem on Writing file line
 
Quote:

Originally Posted by 8guawong (Post 2647738)
did you check your error logs?
i'm pretty sure there will be errors since you didn't check if client is in game like in your other for loop

No there aren't errors. But is spams like this the admin_simple.ini

Example: my steam id is "123", immunity 99 and flags "z" and name //name of the player. It spams like this:

Code:

"123" "99:z" //name of player1
"123" "99:z" //name of player2
"123" "99:z" //name of player3
"123" "99:z" //name of player4
"123" "99:z" //name of player5

Is there any way to fix this??

8guawong 04-16-2019 13:56

Re: Problem on Writing file line
 
Quote:

Originally Posted by SpirT (Post 2647793)
No there aren't errors. But is spams like this the admin_simple.ini

Example: my steam id is "123", immunity 99 and flags "z" and name //name of the player. It spams like this:

Code:

"123" "99:z" //name of player1
"123" "99:z" //name of player2
"123" "99:z" //name of player3
"123" "99:z" //name of player4
"123" "99:z" //name of player5

Is there any way to fix this??

what is the result you want?

8guawong 04-16-2019 14:05

Re: Problem on Writing file line
 
plz show the full code cuz your snippet just looks wrong

farawayf 04-16-2019 16:32

Re: Problem on Writing file line
 
remove int loop, replace "i" to "target" in GetClientAuthId

SpirT 04-17-2019 06:16

Re: Problem on Writing file line
 
Quote:

Originally Posted by farawayf (Post 2647819)
remove int loop, replace "i" to "target" in GetClientAuthId

How do you want me do define target??

int target = <code here>??

farawayf 04-17-2019 07:59

Re: Problem on Writing file line
 
Spamming lines because function are inside of a player loop, which means functions will be performed for the number of players.

the code is not full.
i do not know the first function is client action or..

if client action

PHP Code:

    new target;
    
decl String:args[128];
    
GetCmdArgString(argssizeof(args));
    
target FindTarget(clientargstruefalse); 

if menu handle - "new target;"


All times are GMT -4. The time now is 05:56.

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