Whats wrong with my GivePlayerMoney(killerid
#1

it give me wrong: invalid function or declaration

Код:
public OnPlayerDeath(playerid, killerid, reason)
{
        SetPlayerScore(killerid, GetPlayerScore(killerid) + 1); // +1 Score to KillerID
        SetPlayerScore(playerid, GetPlayerScore(playerid) - 1); // -1 Score to PlayerID
        SendDeathMessage(killerid, playerid, reason); // Death Windows
        GivePlayerMoney(playerid, -200); // - 100 to the player get Killed
        GivePlayerMoney(killerid, 457); // + 100 to the killer
        }
	return 1;
}
Reply
#2

pawn Код:
public OnPlayerDeath(playerid, killerid, reason) {
    if (killerid != INVALID_PLAYER_ID) {// The killer ID is not an invalid player
        SetPlayerScore(killerid, GetPlayerScore(killerid) + 1); // +1 score to killer
        GivePlayerMoney(killerid, 457); // +475 to killer
    }
    GivePlayerMoney(playerid, -200);
    SetPlayerScore(playerid, GetPlayerScore(playerid) - 1);
    SendDeathMessage(killerid, playerid, reason);
    return 1;
}
You have a random closing bracket (}) there.
Reply
#3

First of all, you should check if killerid is actually valid. If a player dies without a killer (suicide), killerid will be 0xFFFF, which is 65535. If you use this is an array, it will more than likely (unless you use a stupidly over-sized array) be out of bounds, which will halt the code and nothing else in that function will be executed.

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    SendDeathMessage(killerid, playerid, reason); // Death Windows

    if(killerid != INVALID_PLAYER_ID)
    {
        SetPlayerScore(killerid, GetPlayerScore(killerid) + 1); // +1 Score to KillerID
        GivePlayerMoney(killerid, 457); // + 100 to the killer
    }

    SetPlayerScore(playerid, GetPlayerScore(playerid) - 1); // -1 Score to PlayerID
    GivePlayerMoney(playerid, -200); // - 100 to the player get Killed
    return 1;
}
You don't need to check if killerid is valid for SendDeathMessage. If you do, when a player dies without a killer you won't see the death message.

As for your error, you need to say which line the error is on. i.e. show it in the code you post. Don't just say the line number because we don't know your line numbers.

Also, use PAWN tags not CODE tags.
Reply
#4

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
        if(killerid != INVALID_PLAYER_ID)
        {
             SetPlayerScore(killerid, GetPlayerScore(killerid) + 1); // +1 Score to KillerID
             GivePlayerMoney(killerid, 457); // + 100 to the killer
        }

        SendDeathMessage(killerid, playerid, reason); // Death Windows
        GivePlayerMoney(playerid, -200); // - 100 to the player get Killed

        SetPlayerScore(playerid, GetPlayerScore(playerid) - 1); // -1 Score to PlayerID
//      } This goes wrong here.
    return 1;
}
Reply
#5

Quote:
Originally Posted by Private200
Посмотреть сообщение
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
        SetPlayerScore(killerid, GetPlayerScore(killerid) + 1); // +1 Score to KillerID
        SetPlayerScore(playerid, GetPlayerScore(playerid) - 1); // -1 Score to PlayerID
        SendDeathMessage(killerid, playerid, reason); // Death Windows
        GivePlayerMoney(playerid, -200); // - 100 to the player get Killed
        GivePlayerMoney(killerid, 457); // + 100 to the killer
//      } This goes wrong here.
    return 1;
}
Read MP2's post. You should check if the killerid is an INVALID_PLAYER.
Quote:
Originally Posted by MP2
First of all, you should check if killerid is actually valid.
Reply
#6

Quote:
Originally Posted by greentarch
Посмотреть сообщение
Read MP2's post. You should check if the killerid is an INVALID_PLAYER.
Edited it from the post creation moment.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)