24.11.2016, 00:33
When a player kills another player, their scores are not going up. Here's the OnPlayerDeath code.
http://pastebin.com/TcCmfS7j
http://pastebin.com/TcCmfS7j
public OnPlayerDeath(playerid, killerid, reason)
{
SendDeathMessage(killerid, playerid, reason);
if(duelinfo[killerid][induel] == 1)
{
duelinfo[killerid][induel] = 0;
new string[128];
new Float:health = GetPlayerHealth(killerid, health);
format(string, sizeof(string), ""RED"[DUEL] "WHITE"%s(%d) has defeated %s(%d) in a duel with %.2f health left", duelinfo[killerid][playername], killerid, duelinfo[playerid][playername], playerid, health);
SendClientMessageToAll(-1, string);
SetPlayerScore(killerid, GetPlayerScore(killerid) + 2);
GiveCoins(killerid, 2);
PlayerInfo[killerid][pDuelWins] +=1;
PlayerInfo[playerid][pDuelLoses] +=1;
}
GiveCoins(killerid, 1);
PlayerInfo[killerid][pKills] += 1;
PlayerInfo[playerid][pDeaths] += 1;
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
if(killerid == INVALID_PLAYER_ID) return 0;
SendDeathMessage(killerid, playerid, reason);
if(duelinfo[killerid][induel] == 1)
{
duelinfo[killerid][induel] = 0;
new string[128];
new Float:health = GetPlayerHealth(killerid, health);
format(string, sizeof(string), ""RED"[DUEL] "WHITE"%s(%d) has defeated %s(%d) in a duel with %.2f health left", duelinfo[killerid][playername], killerid, duelinfo[playerid][playername], playerid, health);
SendClientMessageToAll(-1, string);
SetPlayerScore(killerid, GetPlayerScore(killerid) + 2);
GiveCoins(killerid, 2);
PlayerInfo[killerid][pDuelWins] +=1;
PlayerInfo[playerid][pDuelLoses] +=1;
}
else if(duelinfo[killerid][induel] != 1)
{
GiveCoins(killerid, 1);
SetPlayerScore(killerid, GetPlayerScore(killerid) + 1);
PlayerInfo[killerid][pKills] += 1;
PlayerInfo[playerid][pDeaths] += 1;
}
return 1;
}
Try this
PHP код:
|
"You MUST check whether 'killerid' is valid (not INVALID_PLAYER_ID) before using it in an array (or really anywhere), as it will cause the OnPlayerDeath script to crash |
if(killerid == INVALID_PLAYER_ID) return 0;
PHP код:
|
public OnPlayerDeath(playerid, killerid, reason)
{
if(killerid != INVALID_PLAYER_ID)
{
SendDeathMessage(killerid, playerid, reason);
if(duelinfo[killerid][induel] == 1)
{
duelinfo[killerid][induel] = 0;
new string[128];
new Float:health = GetPlayerHealth(killerid, health);
format(string, sizeof(string), ""RED"[DUEL] "WHITE"%s(%d) has defeated %s(%d) in a duel with %.2f health left", duelinfo[killerid][playername], killerid, duelinfo[playerid][playername], playerid, health);
SendClientMessageToAll(-1, string);
SetPlayerScore(killerid, GetPlayerScore(killerid) + 2);
GiveCoins(killerid, 2);
PlayerInfo[killerid][pDuelWins] +=1;
PlayerInfo[playerid][pDuelLoses] +=1;
}
else if(duelinfo[killerid][induel] != 1)
{
GiveCoins(killerid, 1);
SetPlayerScore(killerid, GetPlayerScore(killerid) + 1);
PlayerInfo[killerid][pKills] += 1;
PlayerInfo[playerid][pDeaths] += 1;
}
}
return 1;
}
PHP код:
|
public OnPlayerDeath(playerid, killerid, reason)
{
SendDeathMessage(killerid, playerid, reason);
if(killerid != INVALID_PLAYER_ID && duelinfo[killerid][induel] == 1)
{
duelinfo[killerid][induel] = 0;
new string[128],Float:health = GetPlayerHealth(killerid, health);
format(string, sizeof(string), ""RED"[DUEL] "WHITE"%s(%d) has defeated %s(%d) in a duel with %.2f health left", duelinfo[killerid][playername], killerid, duelinfo[playerid][playername], playerid, health);
SendClientMessageToAll(-1, string);
SetPlayerScore(killerid, GetPlayerScore(killerid) + 2);
GiveCoins(killerid, 2);
PlayerInfo[killerid][pDuelWins] +=1;
PlayerInfo[playerid][pDuelLoses] +=1;
}
else
{
if(killerid != INVALID_PLAYER_ID)
{
GiveCoins(killerid, 1);
SetPlayerScore(killerid, GetPlayerScore(killerid) + 1);
PlayerInfo[killerid][pKills] += 1;
}
PlayerInfo[playerid][pDeaths] += 1;
}
return 1;
}