21.11.2010, 17:36
How can I do like if one player does /bounty ID AMOUNt, then this player is target, and anyone who kills him, gets this amount.
new pWanted[MAX_PLAYERS];
CMD:bounty(playerid, params[])
{
new pID, Amount;
if(sscanf(params, "ui", pID, Amount)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /Bounty < PlayerID > < Amount >");
pWanted[pID] = Amount;
return 1;
}
public OnPlayerDeath(....)
{
if(pWanted[playerid] >= 0)
{
GivePlayerMoney(killerid, pWanted[playerid]);
pWanted[playerid] = 0;
}
return 1;
}
pWanted[pID] = Amount;
Not going to fully make it, but get an idea from this:
pawn Код:
|
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;
}
I need it too.
Hmm, Can you explane more abit ? Like, Код:
pWanted[pID] = Amount; |