Credits aren't saving
#1

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

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

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

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)