Fix this small code ill +rep
#1

pawn Код:
for (new i = 0; i < MAX_PLAYERS; i++)
 {
 kill[killerid]++;
 death[playerid]++;
 SetPlayerScore(i)(killerid,GetPlayerScore(playerid)+1[i]);
 SetPlayerMoney(killerid,GetPlayerMoney(playerid)+1000);
 SendClientMessage(killerid,COLOR_YELLOW,"You recieved +1000 money & +1 score.");
 }
i wanna use sscanf for kills otherwise the killer gets the same score that the player who died has
Reply
#2

Remove the for (new i = 0; i < MAX_PLAYERS; i++) because that makes it so everyone gains the score if theres a kill if im right.
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    kill[killerid]++;
    death[playerid]++;
    SetPlayerScorekillerid,GetPlayerScore(killerid)+1); //changed playerid to killerid
    SetPlayerMoney(killerid,GetPlayerMoney(killerid)+1000); //changed playerid to killerid because you have the person who died the cash and points.
    SendClientMessage(killerid,COLOR_YELLOW,"You recieved +1000 money & +1 score.");
}
if this doesnt work without the (new i = 0; i < MAX_PLAYERS; i++) you could try adding it back but i reccomend trying it without first and with the above code. good luck ;0!
Reply
#3

Do you even what sscanf is? Sscanf is used to split a string. You do not need it at all.

The bad thing you do is loop through all the players and if there are 50 players, it will add 50 kills to the killer and 50 deaths to the player. It will also cause runtime error about index out of bounds if you do not check if the killer is valid. Your problem is that you get the player's score and add +1000, not the killer's one.

pawn Код:
public OnPlayerDeath( playerid, killerid, reason )
{
    death[playerid]++;
    if( killerid != INVALID_PLAYER_ID )
    {
        kill[ killerid ]++;
        SetPlayerScore( killerid, GetPlayerScore( killerid ) + 1 );
        SetPlayerMoney( killerid, GetPlayerMoney( killerid ) + 1000 );
        SendClientMessage( killerid, COLOR_YELLOW, "You recieved +1000 money & +1 score." );
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)