Not keeping score :(
#1

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;
}
Reply
#2

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;
}
Reply
#3

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

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);
}
Reply
#5

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
Reply
#6

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

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

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;
}
Reply
#9

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

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


Forum Jump:


Users browsing this thread: 5 Guest(s)