PlayerInfo
#1

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;
}
Reply
#2

Код:
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;
}
Reply
#3

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

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.
Reply
#5

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
Reply
#6

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;

Reply
#7

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
Reply


Forum Jump:


Users browsing this thread: