SA-MP Forums Archive
killing - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: killing (/showthread.php?tid=110731)



killing - PANNA - 28.11.2009

how can i make it like when someone kill another person he get +10 score, i tried it myself but i get everytime errors.


Re: killing - Remi-X - 28.11.2009

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
  if(IsPlayerConnected(killerid))
  {
    new score = GetPlayerScore(killerid);
    SetPlayerScore(killerid, score+10);
  }
  return 1;
}



Re: killing - diesulke - 28.11.2009

Remi that code will give the player who died +10 points.

Код:
public OnPlayerDeath(playerid, killerid, reason)
{
  new playercash;
	if(killerid == INVALID_PLAYER_ID) {
    SendDeathMessage(INVALID_PLAYER_ID,playerid,reason);
    ResetPlayerMoney(playerid);
	} else {
	  	SendDeathMessage(killerid,playerid,reason);
			SetPlayerScore(killerid,GetPlayerScore(killerid)+10);
   	}
 	return 1;
}



Re: killing - Correlli - 28.11.2009

Quote:
Originally Posted by diesulke
Remi that code will give the player who died +10 points.
No, it won't. He's using 'killerid' param, not 'playerid'.


Re: killing - Remi-X - 28.11.2009

Indeed. What you're doing diesulke, does exactly the same as my script.


Re: killing - PANNA - 28.11.2009

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
  new playercash;
    if(killerid == INVALID_PLAYER_ID) {
    SendDeathMessage(INVALID_PLAYER_ID,playerid,reason);
    ResetPlayerMoney(playerid);
    } else {
        SendDeathMessage(killerid,playerid,reason);
            SetPlayerScore(killerid,GetPlayerScore(killerid)+10);
            GameTextForPlayer(playerid, "+10!",3000,4);
    }
    return 1;
}

i have it now like that but when i kill someone, get the person wich i killed seen +10 as gametext, can you please set that to the killer?


Re: killing - Correlli - 28.11.2009

Because there is 'playerid' param in the GameTextForPlayer function, it should be 'killerid'.


Re: killing - dice7 - 28.11.2009

Why is this useful ?
pawn Код:
if(killerid == INVALID_PLAYER_ID) {
    SendDeathMessage(INVALID_PLAYER_ID,playerid,reason);
It's the same as
pawn Код:
if(a == 5)
{printf("5");}
else
{printf("%d", a);}