Код HTML:
#define FILTERSCRIPT
#include <a_samp>
#include <streamer>
#include <YSI\y_commands>
#include <sscanf2>
new personalbountys = 0;
new defaultbounty = 50000;
stock GetPlayersName(playerid)
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
for(new i = 0; i < MAX_PLAYER_NAME; i++)
{
if(name[i] == '_') name[i] = ' ';
}
return name;
}
stock ConvertPrice(price)
{
new pricestring[32];
new j = valstr(pricestring,price);
while(j >= 4) { j -= 3; strins(pricestring,",",j); }
strins(pricestring,"$",0);
return pricestring;
}
public OnFilterScriptInit()
{
return 1;
}
public OnFilterScriptExit()
{
return 1;
}
public OnPlayerConnect(playerid)
{
SetPVarInt(playerid, "BountyOnHead", 0);
SetPVarInt(playerid, "BountyAmount", 0);
SetPVarString(playerid, "BountySetBy", "No one");
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
new string[126];
if(killerid != INVALID_PLAYER_ID)
{
if(GetPVarInt(playerid, "BountyOnHead") == 1)
{
new bountyamount = GetPVarInt(playerid, "BountyAmount");
SetPVarInt(playerid, "BountyOnHead", 0);
SetPVarInt(playerid, "BountyAmount", 0);
SetPVarString(playerid, "BountySetBy", "No one");
format(string, sizeof(string), "Bounty Information:{FFFFFF} %s just killed %s for a bounty total of: %s", GetPlayersName(killerid), GetPlayersName(playerid), ConvertPrice(bountyamount));
SendClientMessageToAll(0xFF0000C8, string);
GivePlayerMoney(killerid, bountyamount);
SetPlayerColor(playerid, 0xFFFFFF00);
}
}
return 1;
}
public OnPlayerUpdate(playerid)
{
new string[126];
if(GetPVarInt(playerid, "BountyOnHead") == 0) {
if(GetPlayerWantedLevel(playerid) > 5)
{
SetPVarInt(playerid, "BountyOnHead", 1);
SetPVarInt(playerid, "BountyAmount", defaultbounty);
SetPVarString(playerid, "BountySetBy", "Law Enforcement");
SetPlayerColor(playerid, 0xFF0000C8);
SendClientMessage(playerid, 0xFF0000C8, "Bounty Information:{FFFFFF} Your wanted level has reached Six (6), there fore you have now got a bounty on your head. Watch out!");
format(string, sizeof(string), "Bounty Information:{FFFFFF} %s has been given an automatic bounty of %s, go collect your reward!", GetPlayersName(playerid), ConvertPrice(GetPVarInt(playerid, "BountyAmount")));
SendClientMessageToAll(0xFF0000C8, string);
return 1;
}
}
return 1;
}
public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
new string[126];
if(GetPVarInt(clickedplayerid, "BountyOnHead") == 1)
{
new clickedname[MAX_PLAYER_NAME+1];
format(string, sizeof(string), "Bounty Amount: %s\nSet By: %s", ConvertPrice(GetPVarInt(clickedplayerid, "BountyAmount")), GetPVarString(clickedplayerid, "BountySetBy", clickedname, MAX_PLAYER_NAME+1));
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_MSGBOX, "Bounty Information", string, "Okay", "");
}
return 1;
}
CMD:setdefaultbounty(playerid, params[])
{
new string[126];
if(IsPlayerAdmin(playerid))
{
new amount;
if(sscanf(params, "d", amount)) return SendClientMessage(playerid, 0xFF0000C8, "Bounty Information: /setdefaultbounty [amount]");
if(amount < 0) return SendClientMessage(playerid, 0xFF0000C8, "Bounty Information: A default bounty can not go below $0.");
defaultbounty = amount;
format(string, sizeof(string), "Bounty Information:{FFFFFF} The default bounty amount is now %s.", ConvertPrice(amount));
SendClientMessageToAll(0xFF0000C8, string);
}
return 1;
}
CMD:personalbountys(playerid, params[])
{
if(IsPlayerAdmin(playerid))
{
if(personalbountys == 0)
{
personalbountys = 1;
SendClientMessageToAll(0xFF0000C8, "Bounty Information:{FFFFFF} Personal bountys are now enabled.");
}
else if(personalbountys == 1)
{
personalbountys = 0;
SendClientMessageToAll(0xFF0000C8, "Bounty Information:{FFFFFF} Personal bountys are now disbaled.");
}
}
return 1;
}
CMD:givebounty(playerid, params[])
{
if(personalbountys == 0) return SendClientMessage(playerid, 0xFF0000C8, "Bounty Information:{FFFFFF} Personal bountys are currently disabled.");
new target, amount, string[126];
if(sscanf(params, "ud", target, amount)) return SendClientMessage(playerid, 0xFF0000C8, "Bounty Information:{FFFFFF} /givebounty [target] [bounty amount]");
if(amount > GetPlayerMoney(playerid)) return SendClientMessage(playerid, 0xFF0000C8, "Bounty Information:{FFFFFF} You do not have that much money to place that bounty.");
if(target == playerid) return SendClientMessage(playerid, 0xFFFFFF00, "Bounty Information:{FFFFFF} You can't set a bounty on your self.");
if(GetPVarInt(target, "BountyOnHead") == 1) return SendClientMessage(playerid, 0xFF0000C8, "Bounty Information:{FFFFFF} That player already has a bounty on them.");
if(IsPlayerConnected(target))
{
format(string, sizeof(string), "Bounty Information:{FFFFFF} %s has just set a bounty on %s for the sum of %s!", GetPlayersName(playerid), GetPlayersName(target), ConvertPrice(amount));
SendClientMessageToAll(0xFF0000C8, string);
SetPVarInt(target, "BountyOnHead", 1);
SetPVarInt(target, "BountyAmount", amount);
SetPVarString(target, "BountySetBy", GetPlayersName(playerid));
GivePlayerMoney(playerid, -amount);
SetPlayerColor(target, 0x000000FF);
return 1;
}
else if(!IsPlayerConnected(target))
{
SendClientMessage(playerid, 0xFF0000C8, "Bounty Information:{FFFFFF} That player isn't connected.");
}
return 1;
}