It doesnt load the cash,to give it
#1

Код:
#define PATH "/Users/%s.ini"

new pCash[MAX_PLAYERS];

forward LoadUser_data(playerid, name[], value[]);
public LoadUser_data(playerid, name[], value[])
{
	INI_Int("Player Money", pCash[playerid]);

	return 1;
}

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

main()
{
	print("\n----------------------------------");
	print(" Reg system testing");
	print("----------------------------------\n");
	
	
}


public OnPlayerConnect(playerid)
{
	return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
	new INI:File = INI_Open(UserPath(playerid));
	INI_SetTag(File, "data");
	INI_WriteInt(File, "Player Money", GetPlayerMoney(playerid));
	INI_Close(File);
	return 1;
}

public OnPlayerSpawn(playerid)
{
    if(fexist(UserPath(playerid)))
	{
	    SendClientMessage(playerid, 0xFFF0F0FC, "You're already registered.Your money is saved");
	    INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra=true, .extra=playerid);
	    GivePlayerMoney(playerid, pCash[playerid]);

	}
	else
	{
	    SendClientMessage(playerid, 0xFFF0F0FC, "You're not registered.");
	}
	return 1;
}
This is the file where the cash is stored:
Код:
[data]
Player Money = 1000
When you come ingame for first time,it sets the money to 0,but i edited it and set it to 1000,to check if it will load it on next come in game,and give it to player.But it doesn't.I does says you're registered when you come second time,but won't give the cash.
Reply
#2

It's just all messed up, Follow Kush's tutorial:

https://sampforum.blast.hk/showthread.php?tid=273088
Reply
#3

I followed it,but i tried to leave out some things...i'll just follow the whole thing and then inspect it...
Reply
#4

This code is completely messed up, i recommend you to follow one of the tutorials.
Reply
#5

I'm not sure if this will work in your case but you can try it:
pawn Код:
ResetPlayerMoney(playerid);
GivePlayerMoney(playerid, pInfo[playerid][pCash]);
EDIT: Don't you use an enumerator ?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)