SA-MP Forums Archive
PlayerInfo - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: PlayerInfo (/showthread.php?tid=469778)



PlayerInfo - AnonScripter - 14.10.2013

why this doesn't work ? it create the user file and the money and score is 0 in the file, not the value that i put.
so when player register and spawn, his money and score is 0

pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch(dialogid)
    {
        case DIALOG_REGISTER:
        {
            if (!response) return Kick(playerid);
            if(response)
            {
                if(strlen(inputtext))
                {
                    new INI:File = INI_Open(UserPath(playerid));
                    INI_SetTag(File,"data");
                    INI_WriteInt(File,"Password",udb_hash(inputtext));
                    INI_WriteInt(File,"Cash",15000);
                    INI_WriteInt(File,"Score",5);
                    INI_Close(File);
                }
            }
        }
    }
    return 1;
}

public OnPlayerSpawn(playerid)
{
    GivePlayerMoney(playerid,PlayerInfo[playerid][pCash]
    SetPlayerScore(playerid,PlayerInfo[playerid][pScore]
    return 1;
}



Re: PlayerInfo - rickisme - 14.10.2013

Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch(dialogid)
    {
        case DIALOG_REGISTER:
        {
            if (!response) return Kick(playerid);
            if(response)
            {
                if(strlen(inputtext))
                {
                    new INI:File = INI_Open(UserPath(playerid));
                    INI_SetTag(File,"data");
                    INI_WriteInt(File,"Password",udb_hash(inputtext));
                    INI_WriteInt(File,"Cash",15000);
                    INI_WriteInt(File,"Score",5);
                    INI_Close(File);
                    PlayerInfo[playerid][pCash] = 15000;
                    PlayerInfo[playerid][pScore] = 5;
                    SpawnPlayer(playerid);
                }
            }
        }
    }
    return 1;
}

public OnPlayerSpawn(playerid)
{
    GivePlayerMoney(playerid,PlayerInfo[playerid][pCash])
    SetPlayerScore(playerid,PlayerInfo[playerid][pScore])
    return 1;
}



Re: PlayerInfo - AnonScripter - 14.10.2013

it gives 5 of score and 30k of money, why this?


Re: PlayerInfo - Konstantinos - 14.10.2013

Like you said, it writes them to the file, it does not set the to the player.

pawn Код:
if(strlen(inputtext))
{
    new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File,"data");
    INI_WriteInt(File,"Password",udb_hash(inputtext));
    INI_WriteInt(File,"Cash",15000);
    INI_WriteInt(File,"Score",5);
    INI_Close(File);
    PlayerInfo[playerid][pCash] = 15000;
    PlayerInfo[playerid][pScore] = 5;
    GivePlayerMoney(playerid,PlayerInfo[playerid][pCash]);
    SetPlayerScore(playerid,PlayerInfo[playerid][pScore]);
}
Do not give money in OnPlayerSpawn, if you have (let's say) 50k, then everytime you re-spawn, you're going to get +50k.


Re: PlayerInfo - AnonScripter - 14.10.2013

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
Like you said, it writes them to the file, it does not set the to the player.

pawn Код:
if(strlen(inputtext))
{
    new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File,"data");
    INI_WriteInt(File,"Password",udb_hash(inputtext));
    INI_WriteInt(File,"Cash",15000);
    INI_WriteInt(File,"Score",5);
    INI_Close(File);
    PlayerInfo[playerid][pCash] = 15000;
    PlayerInfo[playerid][pScore] = 5;
    GivePlayerMoney(playerid,PlayerInfo[playerid][pCash]);
    SetPlayerScore(playerid,PlayerInfo[playerid][pScore]);
}
Do not give money in OnPlayerSpawn, if you have (let's say) 50k, then everytime you re-spawn, you're going to get +50k.
i noticed that, thank you for helping, it worked


Re: PlayerInfo - thomaswilliams - 14.10.2013

Here try this:

PHP код:
public OnDialogResponse(playeriddialogidresponselistiteminputtext[])
{
    switch(
dialogid)
    {
        case 
DIALOG_REGISTER:
        {
            if (!
response) return Kick(playerid);
            if(
response)
            {
                if(
strlen(inputtext))
                {
                    new 
INI:File INI_Open(UserPath(playerid));
                    
INI_SetTag(File,"data");
                    
INI_WriteInt(File,"Password",udb_hash(inputtext));
                    
INI_WriteInt(File,"Cash",15000);
                    
INI_WriteInt(File,"Score",5);
                    
INI_Close(File);
                    
PlayerInfo[playerid][pCash] = 15000;
                    
PlayerInfo[playerid][pScore] = 5;
                    
SpawnPlayer(playerid);
                }
            }
        }
    }
    return 
1;
}
public 
OnPlayerSpawn(playerid)
{
    
GivePlayerMoney(playerid,PlayerInfo[playerid][pCash])
    
SetPlayerScore(playerid,PlayerInfo[playerid][pScore])
    return 
1;




Re: PlayerInfo - AnonScripter - 14.10.2013

Quote:
Originally Posted by thomaswilliams
Посмотреть сообщение
Here try this:

PHP код:
public OnDialogResponse(playeriddialogidresponselistiteminputtext[])
{
    switch(
dialogid)
    {
        case 
DIALOG_REGISTER:
        {
            if (!
response) return Kick(playerid);
            if(
response)
            {
                if(
strlen(inputtext))
                {
                    new 
INI:File INI_Open(UserPath(playerid));
                    
INI_SetTag(File,"data");
                    
INI_WriteInt(File,"Password",udb_hash(inputtext));
                    
INI_WriteInt(File,"Cash",15000);
                    
INI_WriteInt(File,"Score",5);
                    
INI_Close(File);
                    
PlayerInfo[playerid][pCash] = 15000;
                    
PlayerInfo[playerid][pScore] = 5;
                    
SpawnPlayer(playerid);
                }
            }
        }
    }
    return 
1;
}
public 
OnPlayerSpawn(playerid)
{
    
GivePlayerMoney(playerid,PlayerInfo[playerid][pCash])
    
SetPlayerScore(playerid,PlayerInfo[playerid][pScore])
    return 
1;

Sorry but please read the full topic before posting, rickisme told me the same method of yours and didn't work, it worked with Konstantinos's method, thanks for replying