Kill reward Not Working properly - 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)
+--- Thread: Kill reward Not Working properly (
/showthread.php?tid=648749)
Kill reward Not Working properly -
Jokers98s - 28.01.2018
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 i : Player)
{
if(GetPlayerClanId(i) == 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);
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;
}
Re: Kill reward Not Working properly -
iSteve - 28.01.2018
Код:
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
Re: Kill reward Not Working properly -
Jokers98s - 28.01.2018
Thanks. Beware of it OK thanks