On Player Death.. (rep++)
#1

Hey Guys!!
====> I want, When some player killed other player than the killer get 200$ and 1 score!! and when player die he get -100$
Can You Help Me
Reply
#2

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    SetPlayerScore(killerid,(GetPlayerScore(killerid))+1);
    GivePlayerMoney(killerid, 200);
    GivePlayerMoney(playerid, -100);
     return 1;
}
Reply
#3

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    if(killerid != INVALID_PLAYER_ID)
    {
          SetPlayerScore(killerid, GetPlayerScore(killerid)+1);
          GivePlayerMoney(killerid, 200);
          SendClientMessage(killerid, -1, "You received 200$ and 1 score.");
          GivePlayerMoney(playerid, -100);
          SendClientMessage(playerid, -1, "You lost 100$ because you got killed.");
          return 1;
     }
}
You need to check if killerid is not invalid player.
Reply
#4

PHP код:
public OnPlayerDeath(playeridkilleridreason)
{
    if(
killerid != INVALID_PLAYER_ID)
    {
          new 
string[256];
          
SetPlayerScore(killerid,(GetPlayerScore(killerid))+1); 
          
GivePlayerMoney(killerid200);
          
SendClientMessage(killerid, -1"You received 200$ and 1 score.");
          
GivePlayerMoney(playerid, -100);
          
SendClientMessage(playerid, -1"You lost 100$ because you got killed.");
          
format(stringsizeof(string), " %s Has killed a enemy!"PlayerName[playerid]);
          
SendClientMessageToAll(COLOR_REDstring);
          return 
1;
     }

look's better
Reply
#5

Thnx All of u (rep added)
== but i added vyper's reply
it say this:
Quote:

D:\Game\SA-MP Files\GM\gamemodes\Wars.pwn(243) : warning 209: function "OnPlayerDeath" should return a value
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


1 Warning

.
Reply
#6

Quote:
Originally Posted by Randyy
Посмотреть сообщение
PHP код:
public OnPlayerDeath(playeridkilleridreason)
{
    if(
killerid != INVALID_PLAYER_ID)
    {
          new 
string[256];
          
SetPlayerScore(killerid,(GetPlayerScore(killerid))+1); 
          
GivePlayerMoney(killerid200);
          
SendClientMessage(killerid, -1"You received 200$ and 1 score.");
          
GivePlayerMoney(playerid, -100);
          
SendClientMessage(playerid, -1"You lost 100$ because you got killed.");
          
format(stringsizeof(string), " %s Has killed a enemy!"PlayerName[playerid]);
          
SendClientMessageToAll(COLOR_REDstring);
          return 
1;
     }

look's better
It looks better but you just create a 256 characters long string, which is just NOT NEEDED.

Let's count your string:
Код:
%s Has killed a enemy!
It has exactly 22 CHARACTERS. Let's add the maximum player name to those 22. So 22 + 24 (MAX_PLAYER_NAME) = 46. So, a 46 long string is the maximum you'd need. You created a 256 characters string, which means 210 more characters than needed, which means a huge memory use which you don't need.

ps: iOmar, put a 'return 1' right before you close the bracket ( } ) in the OnPlayerDeath callback.

So:
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
   // BLA BLA CODE HERE
   return 1;
}
Reply
#7

Guys help me! It giving me 1 warninig
Reply
#8

Yeah u got right, What is the warning ?
Reply
#9

Quote:

public OnPlayerDeath(playerid, killerid, reason)
{
if(killerid != INVALID_PLAYER_ID)
{
SetPlayerScore(killerid, GetPlayerScore(killerid)+1);
GivePlayerMoney(killerid, 300);
SendClientMessage(killerid, -1, "Congratulation!You have gained 300$ and +1 score.");
GivePlayerMoney(playerid, -100);
SendClientMessage(playerid, -1, "You lost 100$ because you got killed.");
return 1;
}
}

Here u go!!!! But still getting warning
Reply
#10

what is the warning ?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)