[HELP] SetPlayerScore
#1

I'm trying to make it so that, when the killerid kills someone, it adds 1 score to him
pawn Код:
Line 355: public OnPlayerDeath(playerid, killerid, reason)
Line 356: {
Line 357:    GivePlayerMoney(playerid, -500);
Line 358:    GivePlayerMoney(killerid, 1000);
Line 359:    PlayerInfo[playerid][pDeaths] += 1;
Line 360:    PlayerInfo[killerid][pKills] += 1;
Line 361:    SetPlayerScore(killerid, +1);
Line 362:    SendClientMessage(playerid, COLOR_ORANGE,"For dying, you have lost $500.");
Line 363:    SendClientMessage(killerid, COLOR_ORANGE,"For killing someone, you have received $1000.");
Line 364:    return 1;
Line 365: }
But I get this:
Код:
C:\Users\Matt\Desktop\My Stuff\WC-DM\gamemodes\WC-DM.pwn(361) : error 029: invalid expression, assumed zero
C:\Users\Matt\Desktop\My Stuff\WC-DM\gamemodes\WC-DM.pwn(361) : warning 215: expression has no effect
C:\Users\Matt\Desktop\My Stuff\WC-DM\gamemodes\WC-DM.pwn(361) : error 001: expected token: ";", but found ")"
C:\Users\Matt\Desktop\My Stuff\WC-DM\gamemodes\WC-DM.pwn(361) : error 029: invalid expression, assumed zero
C:\Users\Matt\Desktop\My Stuff\WC-DM\gamemodes\WC-DM.pwn(361) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
Please help.
Reply
#2

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
 {
    GivePlayerMoney(playerid, -500);
    GivePlayerMoney(killerid, 1000);
    PlayerInfo[playerid][pDeaths] += 1;
    PlayerInfo[killerid][pKills] += 1;
    SetPlayerScore(killerid, GetPlayerScore(killerid) + 1);
    SendClientMessage(playerid, COLOR_ORANGE,"For dying, you have lost $500.");
    SendClientMessage(killerid, COLOR_ORANGE,"For killing someone, you have received $1000.");
    return 1;
 }
Reply
#3

THanks D.Prizzy.
Reply
#4

PlayerInfo[killerid][pKills] += 1;

will break if killerid is INVALID_PLAYER_ID. You need to add a check for this.
Reply
#5

Quote:
Originally Posted by MP2
Посмотреть сообщение
PlayerInfo[killerid][pKills] += 1;

will break if killerid is INVALID_PLAYER_ID. You need to add a check for this.
Ok.. What should I add for a Check for it?
Reply
#6

MP2 means check if the killerid is valid playerid. Sorry I can't type the code I'm in a mobile
Reply
#7

pawn Код:
if(killerid != INVALID_PLAYER_ID)
{
    PlayerInfo[killerid][pKills] += 1;
    GivePlayerMoney(killerid, 1000);
    SetPlayerScore(killerid, GetPlayerScore(killerid) + 1);
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)