COMMAND:contract(playerid, params[]) { return 1; } COMMAND:hits(playerid, params[]) { return 1; }
new hit[MAX_PLAYERS]; new isHitman[MAX_PLAYERS];
COMMAND:contract(playerid, params[]) { new id, amount; if(sscanf(params, "ui", id, amount)) return SendClientMessage(playerid, -1, "{A3A1A0}Usage: /contract [id] [amount]"); return 1; }
COMMAND:contract(playerid, params[]) { new id, amount; if(sscanf(params, "ui", id, amount)) return SendClientMessage(playerid, -1, "{A3A1A0}Usage: /contract [id] [amount]"); if(!IsPlayerConnected(id)) return SendClientMessage(playerid, -1, "{A3A1A0}That player is not connected."); return 1; }
if(isHitman[playerid] == 1) return SendClientMessage(playerid, -1, "{A3A1A0}Hitmen can not place contracts.");
if(isHitman[id] == 1) return SendClientMessage(playerid, -1, "{A3A1A0}That player already has the maximum hit on him.");
if(hit[id] == 150000 || hit[id] > 150000) return SendClientMessage(playerid, -1, "{A3A1A0}That player already has the maximum hit on him.");
if(amount < 50000 || amount > 150000) return SendClientMessage(playerid, -1, "{A3A1A0}Hits range from $50,000 - $150,000.");
if(hit[id] + amount > 150000) return SendClientMessage(playerid, -1, "{A3A1A0}That hit is too high for this player, please lower it.");
hit[id] = hit[id] + amount;
new result[128]; new tname[MAX_PLAYER_NAME]; GetPlayerName(id, tname, sizeof(tname)); format(result, sizeof(result), "You have placed a hit of $%i on %s.", amount, tname); SendClientMessage(playerid, -1, result);
new string[128]; format(string, sizeof(string), "HITMAN: A new hit is available. Name: %s | Amount: $%i", tname, hit[id]); for(new i = 0; i < MAX_PLAYERS; i++) { if(IsPlayerConnected(i)) { if(isHitman[i]) { SendClientMessage(i, -1, string); } } }
COMMAND:contract(playerid, params[])
{
new id, amount;
if(sscanf(params, "ui", id, amount)) return SendClientMessage(playerid, -1, "{A3A1A0}Usage: /contract [id] [amount]");
if(!IsPlayerConnected(id)) return SendClientMessage(playerid, -1, "{A3A1A0}That player is not connected.");
if(isHitman[playerid] == 1) return SendClientMessage(playerid, -1, "{A3A1A0}Hitmen can not place contracts.");
if(isHitman[id] == 1) return SendClientMessage(playerid, -1, "{A3A1A0}That player already has the maximum hit on him.");
if(hit[id] == 150000 || hit[id] > 150000) return SendClientMessage(playerid, -1, "{A3A1A0}That player already has the maximum hit on him.");
if(amount < 50000 || amount > 150000) return SendClientMessage(playerid, -1, "{A3A1A0}Hits range from $50,000 - $150,000.");
if(hit[id] + amount > 150000) return SendClientMessage(playerid, -1, "{A3A1A0}That hit is too high for this player, please lower it.");
hit[id] = hit[id] + amount;
new result[128];
new tname[MAX_PLAYER_NAME];
GetPlayerName(id, tname, sizeof(tname));
format(result, sizeof(result), "You have placed a hit of $%i on %s.", amount, tname);
SendClientMessage(playerid, -1, result);
new string[128];
format(string, sizeof(string), "HITMAN: A new hit is available. Name: %s | Amount: $%i", tname, hit[id]);
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(isHitman[i])
{
SendClientMessage(i, -1, string);
}
}
}
return 1;
}
if(killerid != INVALID_PLAYER_ID) {
if(isHitman[killerid] == 1) { }
public OnPlayerDeath(playerid, killerid, reason)
{
if(killerid != INVALID_PLAYER_ID)
{
if(isHitman[killerid] == 1)
{
if(hit[playerid] > 0)
{
GivePlayerMoney(killerid, hit[playerid]);
new result[128];
new tname[MAX_PLAYER_NAME];
GetPlayerName(playerid, tname, sizeof(tname));
format(result, sizeof(result), "HITMAN: You killed %s and collected the hit of $%i!", tname, hit[playerid]);
SendClientMessage(playerid, -1, result);
hit[playerid] = 0;
}
}
}
return 1;
}
COMMAND:hits(playerid, params[])
{
if(isHitman[playerid] == 1)
{
SendClientMessage(playerid, -1, "--- Current available contracts ---");
new string[128];
new tname[MAX_PLAYER_NAME];
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(hit[i] > 0)
{
format(string, sizeof(string), "Name: %s | Amount: %i", tname, hit[i]);
SendClientMessage(playerid, -1, string);
}
}
}
}
return 1;
}
"Did you know?" - You have to reset the player's hit and ishitman value to 0, once they quit.
Otherwise, an unknown player with that playerid will have an hit on him.. |
format(result, sizeof(result), "HITMAN: You killed %s and collected the hit of $%i!", tname, hit[playerid]);
SendClientMessage(killerid, -1, result);
if(!IsPlayerConnected(playerid)) return SendClientMessage(playerid, -1, "{A3A1A0}That player is not connected.");
Nice tutorial.
pawn Code:
|
Shouldn't the IsPlayerConnected in your contract command be "id", not "playerid"?
pawn Code:
|
Yes because we want to send that message to the killer, the hitman.
|