SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 21/03/2018, 05:48 PM   #1
scripter112
Little Clucker
 
Join Date: Feb 2018
Posts: 25
Reputation: 0
Default Help me with this

How can i make script that creates ini file with player’s ip and in that file saves all nicknames that are joined with this ip
scripter112 is offline   Reply With Quote
Old 21/03/2018, 07:06 PM   #2
Maximun
Gangsta
 
Join Date: Jan 2014
Location: Localhost
Posts: 722
Reputation: 52
Default Re: Help me with this

Can you try that?

PHP Code:
//Defines
#define FILE_NAME "here name of the file ini" //File ini directory

//News
new File:hFile;

stock SaveIPuser(playerid
{
    new 
ip[64], pname[24], string[128], str[128];

    
hFile fopen(FILE_NAMEio_write);
    
GetPlayerIp(playeridip64); //Getting the IP of the player
    
GetPlayerName(playeridpname24); // The name of the player
    
format(str256"Pseudo: %s | IP: %s\n\r"pnameip); // The format
    
    
while(fread(hFilestring)) //Reading the file..
    
{
        if(
strcmp(stringpnamefalsestrlen(pname)) == 0// To check if the players name is in the file
        

            
fwrite(hFilestr); // write the string
        
}
        else
        {
            
fwrite(hFilestr);
        }
    }
    
fclose(hFile);

More information? here
Maximun is offline   Reply With Quote
Old 21/03/2018, 07:21 PM   #3
scripter112
Little Clucker
 
Join Date: Feb 2018
Posts: 25
Reputation: 0
Default Re: Help me with this

Quote:
Originally Posted by Maximun View Post
Can you try that?

PHP Code:
//Defines
#define FILE_NAME "here name of the file ini" //File ini directory

//News
new File:hFile;

stock SaveIPuser(playerid
{
    new 
ip[64], pname[24], string[128], str[128];

    
hFile fopen(FILE_NAMEio_write);
    
GetPlayerIp(playeridip64); //Getting the IP of the player
    
GetPlayerName(playeridpname24); // The name of the player
    
format(str256"Pseudo: %s | IP: %s\n\r"pnameip); // The format
    
    
while(fread(hFilestring)) //Reading the file..
    
{
        if(
strcmp(stringpnamefalsestrlen(pname)) == 0// To check if the players name is in the file
        

            
fwrite(hFilestr); // write the string
        
}
        else
        {
            
fwrite(hFilestr);
        }
    }
    
fclose(hFile);

More information? here
Doesn't work
scripter112 is offline   Reply With Quote
Reply

Thread Tools
Display Modes

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



All times are GMT. The time now is 12:58 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.