Kill reward Not Working properly
#1

If i kill an player me and my clan members should get money. But None get. When the Other guy kills he gets the reward.
Here is the code:
PHP код:
if(ccashreward == 1)
        {
            foreach(new 
Player)
            {
                if(
GetPlayerClanId(i) == GetPlayerClanId(killerid))
                {
                    new 
string1[150],string[150];
                    new 
name1[150];
                    
GetPlayerName(iname1sizeof(name1));
                    
format(string1,sizeof(string1),"No Reward For Killing Own Clan Member");
                    
SendClientMessage(playerid,COLOR_RED,string1);
                    
format(string,sizeof(string),"%s has killed %s",name1,Playername);
                    
SendMessageToClanMembers(playerid,COLOR_RED,string);
                }
                else
                {
                    new 
string[150];
                    new 
moneyreward 1000+random(2001);
                    
format(stringsizeof(string), "[Clan]: You've been rewarded %i$ from %s's kill!"moneyrewardPlayername);
                    
SendClientMessage(i0x00FF7FAAstring);
                    
GivePlayerMoney(imoneyreward);
                }
            }
            return 
1;
        } 
Reply
#2

Код:
public OnPlayerDeath(playerid, killerid, reason)
{
	if(GetPlayerClanId(playerid) == GetPlayerClanId(killerid))
    {
          new string1[150],string[150];
          new name1[150];
          GetPlayerName(i, name1, sizeof(name1));
          format(string1,sizeof(string1),"No Reward For Killing Own Clan Member");
          SendClientMessage(playerid,COLOR_RED,string1);
          format(string,sizeof(string),"%s has killed %s",name1,Playername);
          SendMessageToClanMembers(playerid,COLOR_RED,string);
     }
     else
     {
          new string[150];
          new moneyreward = 1000+random(2001);
          foreach(new i : Player)
          {
            if(GetPlayerClanId(i) == GetPlayerClanId(killerid))
            {
		          format(string, sizeof(string), "[Clan]: You've been rewarded %i$ from %s's kill!", moneyreward, Playername);
		          SendClientMessage(i, 0x00FF7FAA, string);
		          GivePlayerMoney(i, moneyreward);
             }
      }

	return 1;
}
Try this

Also
GivePlayerMoney(i, moneyreward)
try not using GivePlayerMoney, since this can be manipulated by users and would allow money hacks to be used,
instead have a variable store the Player's money, eg

new pMoney[MAX_PLAYER];
when you load stats, load the player's money into it and when you save the stats, save this variable
Reply
#3

Thanks. Beware of it OK thanks
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)