new bounty[MAX_PLAYERS]; if(strcmp(cmd, "/hitman", true) == 0) { new tmp[256]; tmp = strtok(cmdtext, idx); if(!strlen(tmp)) { SendClientMessage(playerid, WHITE, "USAGE: /hitman [playerid] [amount]"); return 1; } giveplayerid = strval(tmp); tmp = strtok(cmdtext, idx); if(!strlen(tmp)) { SendClientMessage(playerid, WHITE, "USAGE: /hitman [playerid] [amount]"); return 1; } moneys = strval(tmp); if(moneys > GetPlayerMoney(playerid)) { SendClientMessage(playerid, RED, "You don't have enough money!"); return 1; } if(moneys < 1) { SendClientMessage(playerid, YELLOW, "You need money to place a bounty."); return 1; } if(IsPlayerConnected(giveplayerid)==0) { SendClientMessage(playerid, RED, "That is not a connected player."); return 1; } bounty[giveplayerid]+=moneys; GivePlayerMoney(playerid, 0-moneys); GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer)); GetPlayerName(playerid, sendername, sizeof(sendername)); format(string, sizeof(string), "%s has had a $%d bounty put on his head from %s (total: $%d).", giveplayer, moneys, sendername, bounty[giveplayerid]); SendClientMessageToAll(ORANGE, string); format(string, sizeof(string), "You have had a $%d bounty put on you from %s (id: %d).", moneys, sendername, playerid); SendClientMessage(giveplayerid, RED, string); return 1; } if(strcmp(cmd, "/bounty", true) == 0) { new tmp[256]; tmp = strtok(cmdtext, idx); if(!strlen(tmp)) { SendClientMessage(playerid, WHITE, "USAGE: /bounty [playerid]"); return 1; } giveplayerid = strval(tmp); if(IsPlayerConnected(giveplayerid)) { GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer)); format(string, sizeof(string), "Player %s (id: %d) has a $%d bounty on his head.", giveplayer,giveplayerid,bounty[giveplayerid]); SendClientMessage(playerid, YELLOW, string); } else { SendClientMessage(playerid, RED, "No such player exists!"); } return 1; } if(strcmp(cmd, "/bounties", true) == 0) { new x; SendClientMessage(playerid, GREEN, "Current Bounties:"); for(new i=0; i < MAX_PLAYERS; i++) { if(IsPlayerConnected(i) && bounty[i] > 0) { GetPlayerName(i, giveplayer, sizeof(giveplayer)); format(string, sizeof(string), "%s%s(%d): $%d", string,giveplayer,i,bounty[i]); x++; if(x > 3) { SendClientMessage(playerid, YELLOW, string); x = 0; format(string, sizeof(string), ""); } else { format(string, sizeof(string), "%s, ", string); } } } if(x <= 3 && x > 0) { string[strlen(string)-2] = '.'; SendClientMessage(playerid, YELLOW, string); } return 1; } |
#include <a_samp>
#define GREEN 0x00FF00FF
#define RED 0xFF0000FF
#define YELLOW 0xFFFF00FF
#define WHITE 0xFFFFFFFF
#define ORANGE 0xFF9600FF
new sendername[ MAX_PLAYER_NAME ];
public OnFilterScriptInit()
{
print("\n---------------------------------------");
print("---------- Bounty by Your Name ----------");
print("---------------------------------------\n");
return 1;
}
public OnFilterScriptExit()
{
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
new bounty[MAX_PLAYERS];
new giveplayerid, moneys, giveplayer[MAX_PLAYER_NAME];
new cmd[128];
new string[128];
new idx;
if(strcmp(cmd, "/hitman", true) == 0) {
new tmp[256];
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) {
SendClientMessage(playerid, WHITE, "USAGE: /hitman [playerid] [amount]");
return 1;
}
giveplayerid = strval(tmp);
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) {
SendClientMessage(playerid, WHITE, "USAGE: /hitman [playerid] [amount]");
return 1;
}
moneys = strval(tmp);
if(moneys > GetPlayerMoney(playerid)) {
SendClientMessage(playerid, RED, "You don't have enough money!");
return 1;
}
if(moneys < 1) {
SendClientMessage(playerid, YELLOW, "You need money to place a bounty.");
return 1;
}
if(IsPlayerConnected(giveplayerid)==0) {
SendClientMessage(playerid, RED, "That is not a connected player.");
return 1;
}
bounty[giveplayerid]+=moneys;
GivePlayerMoney(playerid, 0-moneys);
GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
GetPlayerName(playerid, sendername, sizeof(sendername));
format(string, sizeof(string), "%s has had a $%d bounty put on his head from %s (total: $%d).", giveplayer, moneys, sendername, bounty[giveplayerid]);
SendClientMessageToAll(ORANGE, string);
format(string, sizeof(string), "You have had a $%d bounty put on you from %s (id: %d).", moneys, sendername, playerid);
SendClientMessage(giveplayerid, RED, string);
return 1;
}
if(strcmp(cmd, "/bounty", true) == 0) {
new tmp[256];
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) {
SendClientMessage(playerid, WHITE, "USAGE: /bounty [playerid]");
return 1;
}
giveplayerid = strval(tmp);
if(IsPlayerConnected(giveplayerid)) {
GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
format(string, sizeof(string), "Player %s (id: %d) has a $%d bounty on his head.", giveplayer,giveplayerid,bounty[giveplayerid]);
SendClientMessage(playerid, YELLOW, string);
}
else {
SendClientMessage(playerid, RED, "No such player exists!");
}
return 1;
}
if(strcmp(cmd, "/bounties", true) == 0) {
new x;
SendClientMessage(playerid, GREEN, "Current Bounties:");
for(new i=0; i < MAX_PLAYERS; i++) {
if(IsPlayerConnected(i) && bounty[i] > 0) {
GetPlayerName(i, giveplayer, sizeof(giveplayer));
format(string, sizeof(string), "%s%s(%d): $%d", string,giveplayer,i,bounty[i]);
x++;
if(x > 3) {
SendClientMessage(playerid, YELLOW, string);
x = 0;
format(string, sizeof(string), "");
}
else {
format(string, sizeof(string), "%s, ", string);
}
}
}
if(x <= 3 && x > 0) {
string[strlen(string)-2] = '.';
SendClientMessage(playerid, YELLOW, string);
}
return 1;
}
return 0;
}
stock strtok(const str[], &index)
{
new length = strlen(str);
while ((index < length) && (str[index] <= ' '))
{
index++;
}
new offset = index;
new result[20];
while ((index < length) && (str[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
{
result[index - offset] = str[index];
index++;
}
result[index - offset] = EOS;
return result;
}