Money is mutliplying
#1

So i think ive messed up here somewhere and ive tried editing GivePlayerMoney to Setplayermoney but it says it in undefined. Here is what i have right now what causes the players money to double everytime they spawn.

Here is on spawn

Код:
public OnPlayerSpawn(playerid)
{
    if( PVar[ playerid ][ pLastX ] == 0.0 && PVar[ playerid ][ pLastY ] == 0.0 )
    {
        new
            RPos = random( sizeof ( RandSpawns ) );

        SetPlayerPos( playerid, RandSpawns[ RPos ][ 0 ], RandSpawns[ RPos ][ 1 ], RandSpawns[ RPos ][ 2 ] );
    }
    else SetPlayerPos( playerid, PVar[ playerid ][ pLastX ], PVar[ playerid ][ pLastY ], PVar[ playerid ][ pLastZ ] );
    GivePlayerMoney( playerid, PVar[ playerid ][ pMoney ] );
    return 1;
}
And dialog for when you log in.
Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
	new File[50];
	format(File, sizeof(File), PFiles, pName(playerid));
	switch(dialogid)
	{
		case LOGIN:
		{
		    if(response)
		    {
		        if(strlen(inputtext) == 0)
		        {
					new
						iStr[128];

					format(iStr, sizeof(iStr), ""#CBLUE"Welcome back: "#CDGREEN"%s(%d)\n"#CBLUE"Enter your password to login:", pName(playerid), playerid);
					return ShowPlayerDialog(playerid, LOGIN, DIALOG_STYLE_INPUT, ""#CBLUE"Login", iStr, "Login", "Leave");
				}
    			if(strcmp(inputtext, dj(File, "Password", 40), true) == 0)
		    	{
		        	SendClientMessage(playerid, COLOR_LIGHTGREEN, "You are now logged in!");
		        	GivePlayerMoney( playerid, PVar[ playerid ][ pMoney ] );
		        
					PVar[playerid][pKills] 		= djInt		(File, "Kills");
					PVar[playerid][pMoney] 		= djInt		(File, "Money");
					PVar[playerid][pDeaths] 	= djInt		(File, "Deaths");
					PVar[playerid][pLevel] 		= djInt		(File, "Level");
					PVar[playerid][pMuted]      = djInt     (File, "Muted");
					format(PVar[playerid][pMutedReason], 52, "%s", dj(File, "MutedReason"));
					
					PVar[playerid][pLastX]      = djFloat	(File, "LastX");
					PVar[playerid][pLastY]      = djFloat	(File, "LastY");
					PVar[playerid][pLastZ]      = djFloat	(File, "LastZ");
				}
				else
				{
Reply
#2

Remove
pawn Код:
GivePlayerMoney( playerid, PVar[ playerid ][ pMoney ] );
from OnPlayerSpawn.
At dialog response:
pawn Код:
SendClientMessage( playerid, COLOR_LIGHTGREEN, #You are now logged in! );
ResetPlayerMoney( playerid );
GivePlayerMoney( playerid, PVar[ playerid ][ pMoney ] );
Reply
#3

For setplayermoney add:

pawn Код:
forward SetPlayerMoney(playerid, money);
stock SetPlayerMoney(playerid, money) {
    ResetPlayerMoney(playerid);
    GivePlayerMoney(playerid, money);
}
Reply
#4

I tried Sinner method what worked but thanks both of you.
Reply
#5

Put This Under OnPlayerConnect

GivePlayerMoney( playerid, PVar[ playerid ][ pMoney ] );
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)