Not keeping score :( -
Brandondw8 - 14.05.2014
Doesnt add score whern someone dies by another player.
Код:
public OnPlayerDeath(playerid, killerid, reason)
{
// Add 1 to this killer's score. We must check it is valid first.
if(killerid != INVALID_PLAYER_ID)
{
SetPlayerScore(killerid, GetPlayerScore(killerid) + 1);
}
SetPVarInt(playerid, "Dead", 1);
SendDeathMessage(killerid, playerid, reason); // Shows the kill in the killfeed
return 1;
}
Re: Not keeping score :( -
nilanjay - 14.05.2014
pawn Код:
if(killerid != INVALID_PLAYER_ID)
{
SetPlayerScore(killerid, GetPlayerScore(killerid) + 1);
}
This above code of your says that if the killerid is invalid then add +1 to the score of killerid. That's why it is not working.
Try this
pawn Код:
if(killerid != INVALID_PLAYER_ID)
else
{
SetPlayerScore(killerid, GetPlayerScore(killerid) + 1);
}
SetPVarInt(playerid, "Dead", 1);
SendDeathMessage(killerid, playerid, reason); // Shows the kill in the killfeed
return 1;
}
Re: Not keeping score :( -
Brandondw8 - 14.05.2014
Quote:
Originally Posted by nilanjay
pawn Код:
if(killerid != INVALID_PLAYER_ID) { SetPlayerScore(killerid, GetPlayerScore(killerid) + 1); }
This above code of your says that if the killerid is invalid then add +1 to the score of killerid. That's why it is not working.
Try this
pawn Код:
if(killerid != INVALID_PLAYER_ID) else { SetPlayerScore(killerid, GetPlayerScore(killerid) + 1); } SetPVarInt(playerid, "Dead", 1); SendDeathMessage(killerid, playerid, reason); // Shows the kill in the killfeed return 1; }
|
Thank you for the reply. I will take my server down and change the code and shoot someone who joins to test haha.
Re: Not keeping score :( -
Brandondw8 - 14.05.2014
Quote:
Originally Posted by nilanjay
pawn Код:
if(killerid != INVALID_PLAYER_ID) { SetPlayerScore(killerid, GetPlayerScore(killerid) + 1); }
This above code of your says that if the killerid is invalid then add +1 to the score of killerid. That's why it is not working.
Try this
pawn Код:
if(killerid != INVALID_PLAYER_ID) else { SetPlayerScore(killerid, GetPlayerScore(killerid) + 1); } SetPVarInt(playerid, "Dead", 1); SendDeathMessage(killerid, playerid, reason); // Shows the kill in the killfeed return 1; }
|
When compiled, I get this:
error 029: invalid expression, assumed zero
Line 230. Heres lines 227 - 233
public OnPlayerDeath(playerid, killerid, reason)
{
if(killerid != INVALID_PLAYER_ID)
else
{
SetPlayerScore(killerid, GetPlayerScore(killerid) + 1);
}
Re: Not keeping score :( -
nilanjay - 14.05.2014
pawn Код:
if(killerid != INVALID_PLAYER_ID) return SendClientMessage(playerid, -1, "You committed sucide");
else
{
SetPlayerScore(killerid, GetPlayerScore(killerid) + 1);
}
SetPVarInt(playerid, "Dead", 1);
SendDeathMessage(killerid, playerid, reason); // Shows the kill in the killfeed
I am sorry, I forgot to add return after checking the InvalidPlayerID
Re: Not keeping score :( -
Brandondw8 - 14.05.2014
Quote:
Originally Posted by nilanjay
pawn Код:
if(killerid != INVALID_PLAYER_ID) return SendClientMessage(playerid, -1, "You committed sucide"); else { SetPlayerScore(killerid, GetPlayerScore(killerid) + 1); } SetPVarInt(playerid, "Dead", 1); SendDeathMessage(killerid, playerid, reason); // Shows the kill in the killfeed
I am sorry, I forgot to add return after checking the InvalidPlayerID
|
Nice. Compiled with no warn/errors. Thank you.
Let's hope it works. Which I'm sure it will.
Re: Not keeping score :( -
Vince - 14.05.2014
Quote:
Originally Posted by nilanjay
pawn Код:
if(killerid != INVALID_PLAYER_ID) { SetPlayerScore(killerid, GetPlayerScore(killerid) + 1); }
This above code of your says that if the killerid is invalid then add +1 to the score of killerid. That's why it is not working.
|
Go learn your operators, please. It says: if killerid is
not invalid (hence, valid), then add score. This is correct.
Re: Not keeping score :( -
Brandondw8 - 14.05.2014
Quote:
Originally Posted by Vince
Go learn your operators, please. It says: if killerid is not invalid (hence, valid), then add score. This is correct.
|
Have to learn somewhere.
So you're saying I don't need this?:
Код:
return SendClientMessage(playerid, -1, "You committed sucide");
This is my onplayedeath:
Код:
public OnPlayerDeath(playerid, killerid, reason)
{
SetPVarInt(playerid, "Dead", 1);
SendDeathMessage(killerid, playerid, reason); // Shows the kill in the killfeed
if(killerid != INVALID_PLAYER_ID) return SendClientMessage(playerid, -1, "You committed sucide");
else
{
SetPlayerScore(killerid, GetPlayerScore(killerid) + 1);
}
return 1;
}
Re: Not keeping score :( -
Tingesport - 14.05.2014
Quote:
Originally Posted by nilanjay
pawn Код:
if(killerid != INVALID_PLAYER_ID) { SetPlayerScore(killerid, GetPlayerScore(killerid) + 1); }
This above code of your says that if the killerid is invalid then add +1 to the score of killerid. That's why it is not working.
Try this
pawn Код:
if(killerid != INVALID_PLAYER_ID) else { SetPlayerScore(killerid, GetPlayerScore(killerid) + 1); } SetPVarInt(playerid, "Dead", 1); SendDeathMessage(killerid, playerid, reason); // Shows the kill in the killfeed return 1; }
|
The if statement above doesn't do anything at the moment, what it says is that.. if the killer is not a valid ID (Not connected successfully) then add one score to.. no one? Since the player is not connected.
Use Vince's code instead.
Re: Not keeping score :( -
Brandondw8 - 14.05.2014
Quote:
Originally Posted by Tingesport
The if statement above doesn't do anything at the moment, what it says is that.. if the killer is not a valid ID (Not connected successfully) then add one score to.. no one? Since the player is not connected.
Use Vince's code instead.
|
Will do. Thank you. And thanks for replying to my other thread. I will check out the single/double array documentation and try and work on my own script.