OnPlayerDeath - Updating Data -
Slepur - 05.08.2013
I have all valid variables in place and set up... But I can't seem to get the data for Deaths and Kills to add 1 ontop of the current number set on that variable.
Код:
public OnPlayerDeath(playerid, killerid, reason)
{
new PlayerName[MAX_PLAYER_NAME], KillerName[MAX_PLAYER_NAME], string[128];
GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
GetPlayerName(killerid, KillerName, sizeof(KillerName));
format(string, sizeof(string), "%s has been killed by %s!", PlayerName, KillerName);
SendClientMessageToAll(0xFFFFFFFF, string);
pInfo[playerid][pDeaths] += 1;
pInfo[killerid][pKills] += 1;
return 1;
}
Re: OnPlayerDeath - Updating Data -
RedJohn - 05.08.2013
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
new PlayerName[MAX_PLAYER_NAME], KillerName[MAX_PLAYER_NAME], string[128];
GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
GetPlayerName(killerid, KillerName, sizeof(KillerName));
format(string, sizeof(string), "%s has been killed by %s!", PlayerName, KillerName);
SendClientMessageToAll(0xFFFFFFFF, string);
pInfo[playerid][pDeaths]++;
pInfo[killerid][pKills]++;
return 1;
}
++ = Increases by 1.
EDIT: Why don't you use
THIS instead of:
pawn Код:
new PlayerName[MAX_PLAYER_NAME], KillerName[MAX_PLAYER_NAME], string[128];
GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
GetPlayerName(killerid, KillerName, sizeof(KillerName));
format(string, sizeof(string), "%s has been killed by %s!", PlayerName, KillerName);
SendClientMessageToAll(0xFFFFFFFF, string);
Re: OnPlayerDeath - Updating Data -
Slepur - 05.08.2013
Quote:
Originally Posted by RedJohn
pawn Код:
public OnPlayerDeath(playerid, killerid, reason) { new PlayerName[MAX_PLAYER_NAME], KillerName[MAX_PLAYER_NAME], string[128]; GetPlayerName(playerid, PlayerName, sizeof(PlayerName)); GetPlayerName(killerid, KillerName, sizeof(KillerName)); format(string, sizeof(string), "%s has been killed by %s!", PlayerName, KillerName); SendClientMessageToAll(0xFFFFFFFF, string); pInfo[playerid][pDeaths]++; pInfo[killerid][pKills]++; return 1; }
++ = Increases by 1.
EDIT: Why don't you use THIS instead of:
pawn Код:
new PlayerName[MAX_PLAYER_NAME], KillerName[MAX_PLAYER_NAME], string[128]; GetPlayerName(playerid, PlayerName, sizeof(PlayerName)); GetPlayerName(killerid, KillerName, sizeof(KillerName)); format(string, sizeof(string), "%s has been killed by %s!", PlayerName, KillerName); SendClientMessageToAll(0xFFFFFFFF, string);
|
At first I didn't want to use this, but now I come to think of it... It'd be better since the chat won't get spammed out lol.
Thanks dude.
Re: OnPlayerDeath - Updating Data -
RedJohn - 05.08.2013
And in future, simplify your server as much as you can. If you have too many un-optimized code your server will become laggy for those with low PCs. Keep that in mind.
Re: OnPlayerDeath - Updating Data -
Slepur - 05.08.2013
I have updated it but for some reason it's not updating the deaths or kills, still... It also removes $100 from the player who dies rather than the $50 set and doesn't add $100 to the killer.
Код:
public OnPlayerDeath(playerid, killerid, reason)
{
SendDeathMessage(killerid, playerid, reason);
if(killerid != INVALID_PLAYER_ID) // Killer Shit
{
pInfo[killerid][pKills]++;
pInfo[killerid][pScore]++;
pInfo[killerid][pMoney] += 100;
SetPlayerScore(killerid, pInfo[killerid][pScore]);
}
//Dead Shit
pInfo[playerid][pDeaths]++;
pInfo[playerid][pMoney] -= 50;
return 1;
}
Re: OnPlayerDeath - Updating Data -
Amel_PAtomAXx - 05.08.2013
pawn Код:
if(killerid != INVALID_PLAYER_ID) // Killer Shit
{
pInfo[killerid][pKills]++;
pInfo[killerid][pScore]++;
pInfo[killerid][pMoney] = pInfo[killerid][pMoney]+100;
SetPlayerScore(killerid, pInfo[killerid][pScore]);
}
//Dead Shit
pInfo[playerid][pDeaths]++;
pInfo[playerid][pMoney] = pInfo[playerid][pMoney]-50;
return 1;
}
Re: OnPlayerDeath - Updating Data -
RedJohn - 05.08.2013
Quote:
Originally Posted by Amel_PAtomAXx
pawn Код:
if(killerid != INVALID_PLAYER_ID) // Killer Shit { pInfo[killerid][pKills]++; pInfo[killerid][pScore]++; pInfo[killerid][pMoney] = pInfo[killerid][pMoney]+100; SetPlayerScore(killerid, pInfo[killerid][pScore]); } //Dead Shit pInfo[playerid][pDeaths]++; pInfo[playerid][pMoney] = pInfo[playerid][pMoney]-50;
return 1; }
|
Actually correct way is:
pawn Код:
pInfo[playerid][pMoney] = GetPlayerMoney(playerid) - 50;
Re: OnPlayerDeath - Updating Data -
Slepur - 05.08.2013
Okay, but for some reason the pInfo[playerid][pDeaths]++; doesn't seem to update the deaths, same with the score and kills.
Re: OnPlayerDeath - Updating Data -
SuperViper - 05.08.2013
How can you tell that it doesn't update? How are you checking for this?
Re: OnPlayerDeath - Updating Data -
Amel_PAtomAXx - 05.08.2013
Quote:
Originally Posted by RedJohn
Actually correct way is:
pawn Код:
pInfo[playerid][pMoney] = GetPlayerMoney(playerid) - 50;
|
He's running own money system.
pawn Код:
pInfo[playerid][pMoney] = pInfo[playerid][pMoney] - 50;
GivePlayerMoney(playerid, pInfo[playerid][pMoney]);
This should work well...
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
SendDeathMessage(killerid, playerid, reason);
if(killerid != INVALID_PLAYER_ID)
{
pInfo[killerid][pKills] = pInfo[killerid][pKills] + 1;
pInfo[killerid][pScore] = pInfo[killerid][pScore] +1;
pInfo[killerid][pMoney] = pInfo[killerid][pMoney] + 100;
GivePlayerMoney(killerid, pInfo[killerid][pMoney]);
SetPlayerScore(killerid, pInfo[killerid][pScore]);
}
else
{
pInfo[playerid][pDeaths] = pInfo[playerid][pDeaths] + 1;
pInfo[playerid][pMoney] = pInfo[playerid][pMoney] - 50;
GivePlayerMoney(playerid, pInfo[playerid][pMoney]);
}
return 1;
}
Let me now if something goes bad.