SA-MP Forums Archive
Credits aren't saving - 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: Credits aren't saving (/showthread.php?tid=581050)



Credits aren't saving - Pawnify - 10.07.2015

I'm probably doing some bad mistake here... not sure where.. but it's not setting the credits amount on death. It's setting the kills and deaths, but just not the credits.

Код:
public OnPlayerDeath(playerid, killerid, reason)
{
	PlayerInfo[killerid][pKills] ++;
	PlayerInfo[playerid][pDeaths] ++;
	PlayerInfo[killerid][pCredits] = PlayerInfo[killerid][pCredits] + 3;
	PlayerInfo[playerid][pCredits] --;
	return 1;
}
I can however set the credits with a test command that I made here
Код:
COMMAND:byecredits(playerid, params[])
{
	PlayerInfo[playerid][pCredits] --;
	return 1;
}
That one changed the credits amount, when I view the credits here in another test command:
Код:
COMMAND:credits(playerid, params[])
{
	new string[20];
	format(string, sizeof(string), "%d",PlayerInfo[playerid][pCredits]);
	SendClientMessage(playerid, -1, string);
	format(string, sizeof(string), "%d",PlayerInfo[playerid][pDeaths]);
	SendClientMessage(playerid, -1, string);
	return 1;
}
It's just frustrating because I've tried a lot of things and it's the smallest bug ever 0_0 and I can't progress without fixing it.


Re: Credits aren't saving - Dan. - 10.07.2015

Try
Код:
PlayerInfo[killerid][pCredits] += 3;



Re: Credits aren't saving - Pawnify - 10.07.2015

Quote:
Originally Posted by Dan.
Посмотреть сообщение
Try
Код:
PlayerInfo[killerid][pCredits] += 3;
I'm killing myself here in the test so this line wouldn't matter.


Re: Credits aren't saving - woot - 10.07.2015

If you kill yourself then killerid is INVALID_PLAYER_ID (65535) and thus out of PlayerInfo bounds. The rest of your code will not execute because of that.

Before you modify PlayerInfo[killerid], make sure that killerid is not INVALID_PLAYER_ID