getplayerip HELP !
#1

ERROR:
Quote:

warning 202: number of arguments does not match definition

LINE:
pawn Код:
INI_WriteInt(File,"IP",GetPlayerIp(playerid));
So,anyone know how to fix?
Reply
#2

pawn Код:
new ip[16];
GetPlayerIp(playerid, ip, sizeof(ip));
INI_WriteString(File,"IP",ip);
The IP is not a integer. It is a string.
Reply
#3

pawn Код:
new plrIP[16],IPString[24];
    GetPlayerIp(playerid, plrIP, sizeof(plrIP))
format(IPString,sizeof(IPString),"%d",plrIP"));
INI_WriteInt(File,"
IP",IPString);
If that doesn't work.

Try

pawn Код:
new plrIP[16],IPString[24];
    GetPlayerIp(playerid, plrIP, sizeof(plrIP))
format(IPString,sizeof(IPString),"%d",plrIP"));
INI_WriteInt(File,IPString);
Reply
#4

Jake,I still got errors .

pawn Код:
#include < a_samp >
#include < zcmd >
#include < YSI\y_ini >
#include < sscanf2 >

#define DIALOG_REGISTER         1
#define DIALOG_LOGIN            2
#define DIALOG_SUCCESS_REGISTER 3
#define DIALOG_SUCCESS_LOGIN    4
#define DIALOG_RCON_CMDS        5

#define PATH "ACCOUNTS/%s.ini"

#define COL_WHITE               "{FFFFFF}"
#define COL_RED                 "{F81414}"
#define COL_GREEN               "{00FF22}"
#define COL_LIGHTBLUE           "{00CED1}"
#define COL_YELLOW              "{DBED15}"
#define RED                     0xAA3333AA
#define YELLOW                  0xFFFF00AA

#define RCONERRORS              Error: You are'nt Rcon Admin !
#define XCONNECTERRORS          Error: That player is not connected !

enum pInfo
{
    pPass,
    pCash,
    pAdmin,
    pScores,
    pIP,
    pKills,
    pDeaths
}
new PlayerInfo[MAX_PLAYERS][pInfo];

forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{

    INI_Int("Password",PlayerInfo[playerid][pPass]);
    INI_Int("Cash",PlayerInfo[playerid][pCash]);
    INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
    INI_Int("Scores",PlayerInfo[playerid][pScores]);
    INI_Int("IP",PlayerInfo[playerid][pIP]);
    INI_Int("Kills",PlayerInfo[playerid][pKills]);
    INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
    return 1;
}

stock UserPath(playerid)
{
    new string[128],playername[MAX_PLAYER_NAME];
    GetPlayerName(playerid,playername,sizeof(playername));
    format(string,sizeof(string),PATH,playername);
    return string;
}

stock udb_hash(buf[]) {
    new length=strlen(buf);
    new s1 = 1;
    new s2 = 0;
    new n;
    for (n=0; n<length; n++)
    {
       s1 = (s1 + buf[n]) % 65521;
       s2 = (s2 + s1)     % 65521;
    }
    return (s2 << 16) + s1;
}

public OnPlayerConnect(playerid)
{
    if(fexist(UserPath(playerid)))
    {
        INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,""COL_WHITE"*Login*",""COL_WHITE"* Type your "COL_YELLOW"password "COL_WHITE"below to login *","Login","Kick");
    }
    else
    {
        ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD,""COL_WHITE"*Registering*",""COL_WHITE"* Type your "COL_YELLOW"password below to register a new "COL_LIGHTBLUE"account *","Register","Kick");
    }
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    new pIP[16];
    new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File,"Player_Data");
    INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
    INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
    INI_WriteInt(File,"Scores",GetPlayerScore(playerid));
    GetPlayerIp(playerid, pIP, sizeof(pIP));
    INI_WriteString(File,"IP",ip);
    INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
    INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
    INI_Close(File);
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    PlayerInfo[killerid][pKills]++;
    PlayerInfo[playerid][pDeaths]++;
    PlayerInfo[playerid][pScores]++;
    return 1;
}



public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch( dialogid )
    {
        case DIALOG_REGISTER:
        {
            if (!response) return Kick(playerid);
            if(response)
            {
                if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, ""COL_WHITE"*Registering*",""COL_RED"You have entered an invalid password.\n"COL_WHITE"Type your "COL_YELLOW"password below to register a new "COL_LIGHTBLUE"account.","Register","Kick");
                new INI:File = INI_Open(UserPath(playerid));
                INI_SetTag(File,"Player_Data");
                INI_WriteInt(File,"Password",udb_hash(inputtext));
                INI_WriteInt(File,"Cash",0);
                INI_WriteInt(File,"Admin",0);
                INI_WriteInt(File,"Scores",0);
                INI_WriteInt(File,"IP",0);
                INI_WriteInt(File,"Kills",0);
                INI_WriteInt(File,"Deaths",0);
                INI_Close(File);

                SetSpawnInfo(playerid, 0, 0, 1958.33, 1343.12, 15.36, 269.15, 0, 0, 0, 0, 0, 0);
                SpawnPlayer(playerid);
                ShowPlayerDialog(playerid, DIALOG_SUCCESS_REGISTER, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_YELLOW"Thanks for registering !\nYour account succesfully registered !","Ok","");
                        }
        }

        case DIALOG_LOGIN:
        {
            if ( !response ) return Kick ( playerid );
            if( response )
            {
                if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
                {
                    INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
                    GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
                    SetPlayerScore(playerid, PlayerInfo[playerid][pScores]);
                    ShowPlayerDialog(playerid, DIALOG_SUCCESS_LOGIN, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"You have successfully logged in!","Ok","");
                }
                else
                {
                    ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,""COL_WHITE"Login",""COL_RED"You have entered an incorrect "COL_YELLOW"password 1\n"COL_WHITE"Type your "COL_YELLOW"password "COL_WHITE"below to login !","Login","Kick");
                }
                return 1;
            }
        }
    }
    return 1;
}
ERRORS:

Quote:

warning 219: local variable "pIP" shadows a variable at a preceding level
error 035: argument type mismatch (argument 2)
error 035: argument type mismatch (argument 2)
error 017: undefined symbol "ip"
warning 204: symbol is assigned a value that is never used: "pIP"

Reply
#5

Tested:
pawn Код:
new plrIP[16],IPString[24];
                GetPlayerIp(playerid, plrIP, sizeof(plrIP));
                format(IPString,sizeof(IPString),"%s",plrIP);
                INI_WriteString(File,"IP",IPString);
Sorry for the indentation

Outcome:

Код:
IP = 127.0.0.1
Reply
#6

Where i need to put all those codes?
Reply
#7

INI_Int("IP",PlayerInfo[playerid][pIP]); (In LoadUser_data)

IP is a string, INI_String
Reply
#8

I've got them under OnPlayerConnect and OnDialogResponse,for when they register, then save IP each time they login.
Reply
#9

REVO,it gives error

Dobbys,i dont understand.
Can you just add into my script then post it :/
Reply
#10

pawn Код:
#include < a_samp >
#include < zcmd >
#include < YSI\y_ini >
#include < sscanf2 >

#define DIALOG_REGISTER         1
#define DIALOG_LOGIN            2
#define DIALOG_SUCCESS_REGISTER 3
#define DIALOG_SUCCESS_LOGIN    4
#define DIALOG_RCON_CMDS        5

#define PATH "ACCOUNTS/%s.ini"

#define COL_WHITE               "{FFFFFF}"
#define COL_RED                 "{F81414}"
#define COL_GREEN               "{00FF22}"
#define COL_LIGHTBLUE           "{00CED1}"
#define COL_YELLOW              "{DBED15}"
#define RED                     0xAA3333AA
#define YELLOW                  0xFFFF00AA

#define RCONERRORS              Error: You are'nt Rcon Admin !
#define XCONNECTERRORS          Error: That player is not connected !

enum pInfo
{
    pPass,
    pCash,
    pAdmin,
    pScores,
    pIP,
    pKills,
    pDeaths
}
new PlayerInfo[MAX_PLAYERS][pInfo];

forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{

    INI_Int("Password",PlayerInfo[playerid][pPass]);
    INI_Int("Cash",PlayerInfo[playerid][pCash]);
    INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
    INI_Int("Scores",PlayerInfo[playerid][pScores]);
    INI_Int("IP",PlayerInfo[playerid][pIP]);
    INI_Int("Kills",PlayerInfo[playerid][pKills]);
    INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
    return 1;
}

stock UserPath(playerid)
{
    new string[128],playername[MAX_PLAYER_NAME];
    GetPlayerName(playerid,playername,sizeof(playername));
    format(string,sizeof(string),PATH,playername);
    return string;
}

stock udb_hash(buf[]) {
    new length=strlen(buf);
    new s1 = 1;
    new s2 = 0;
    new n;
    for (n=0; n<length; n++)
    {
       s1 = (s1 + buf[n]) % 65521;
       s2 = (s2 + s1)     % 65521;
    }
    return (s2 << 16) + s1;
}

public OnPlayerConnect(playerid)
{
    if(fexist(UserPath(playerid)))
    {
        INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,""COL_WHITE"*Login*",""COL_WHITE"* Type your "COL_YELLOW"password "COL_WHITE"below to login *","Login","Kick");
    }
    else
    {
        ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD,""COL_WHITE"*Registering*",""COL_WHITE"* Type your "COL_YELLOW"password below to register a new "COL_LIGHTBLUE"account *","Register","Kick");
    }
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File,"Player_Data");
    INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
    INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
    INI_WriteInt(File,"Scores",GetPlayerScore(playerid));
    new plrIP[16],IPString[24];
    GetPlayerIp(playerid, plrIP, sizeof(plrIP));
    format(IPString,sizeof(IPString),"%s",plrIP);
    INI_WriteString(File,"IP",IPString);
    INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
    INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
    INI_Close(File);
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    PlayerInfo[killerid][pKills]++;
    PlayerInfo[playerid][pDeaths]++;
    PlayerInfo[playerid][pScores]++;
    return 1;
}



public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch( dialogid )
    {
        case DIALOG_REGISTER:
        {
            if (!response) return Kick(playerid);
            if(response)
            {
                if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, ""COL_WHITE"*Registering*",""COL_RED"You have entered an invalid password.\n"COL_WHITE"Type your "COL_YELLOW"password below to register a new "COL_LIGHTBLUE"account.","Register","Kick");
                new INI:File = INI_Open(UserPath(playerid));
                INI_SetTag(File,"Player_Data");
                INI_WriteInt(File,"Password",udb_hash(inputtext));
                INI_WriteInt(File,"Cash",0);
                INI_WriteInt(File,"Admin",0);
                INI_WriteInt(File,"Scores",0);
                INI_WriteInt(File,"IP",0);
                INI_WriteInt(File,"Kills",0);
                INI_WriteInt(File,"Deaths",0);
                INI_Close(File);

                SetSpawnInfo(playerid, 0, 0, 1958.33, 1343.12, 15.36, 269.15, 0, 0, 0, 0, 0, 0);
                SpawnPlayer(playerid);
                ShowPlayerDialog(playerid, DIALOG_SUCCESS_REGISTER, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_YELLOW"Thanks for registering !\nYour account succesfully registered !","Ok","");
                        }
        }

        case DIALOG_LOGIN:
        {
            if ( !response ) return Kick ( playerid );
            if( response )
            {
                if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
                {
                    INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
                    GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
                    SetPlayerScore(playerid, PlayerInfo[playerid][pScores]);
                    ShowPlayerDialog(playerid, DIALOG_SUCCESS_LOGIN, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"You have successfully logged in!","Ok","");
                }
                else
                {
                    ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,""COL_WHITE"Login",""COL_RED"You have entered an incorrect "COL_YELLOW"password 1\n"COL_WHITE"Type your "COL_YELLOW"password "COL_WHITE"below to login !","Login","Kick");
                }
                return 1;
            }
        }
    }
    return 1;
}
Here you go!.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)