29.08.2012, 03:17
pawn Код:
dcmd_duel(playerid, params[])
{
new
giveplayerid,
weapon[128],
price;
new string[256];
new sendername[MAX_PLAYER_NAME];
new giveplayername[MAX_PLAYER_NAME];
if (sscanf(params, "isi", giveplayerid,weapon,price))
{
SendClientMessage(playerid, COLOR_YELLOW, "[VT ERROR] Right Usage: /dual [playerid] [weapon] [amount]");
SendClientMessage(playerid, COLOR_YELLOW, "Duel weapons: deagle, mp5, chainsaw, silpist, combatsg, shotgun");
return 1;
}
else
{
if(playerid != giveplayerid)
{
GetPlayerName(playerid, sendername, sizeof(sendername));
GetPlayerName(giveplayerid, giveplayername, sizeof(giveplayername));
if(strcmp("deagle", weapon, true, 6) == 0)
{
if(GetPlayerMoney(playerid) >= price)
{
if(Inventation[giveplayerid] == -1)
{
if(InventationSent[playerid] == -1)
{
if(InDual[playerid] == 0)
{
if(InDual[giveplayerid] == 0)
{
if(DualRoom1 == -1)
{
SetTimerEx("inventationremove", 30000, 0, "i", playerid);
format(string, sizeof(string), "%s has sent you a 1 vs. 1 duel with a desert eagle for $%d, /acceptduel or /declineduel", sendername, price);
SendClientMessage(giveplayerid, GREEN, string);
format(string, sizeof(string), "you sent %s a 1 vs. 1 duel with a desert eagle for $%d", giveplayername, price);
SendClientMessage(playerid, GREEN, string);
InventationSent[playerid] = giveplayerid;
Inventation[giveplayerid] = playerid;
Inventationprice[giveplayerid] = price;
DualRoom1price = price;
DualRoom1 = playerid;
WeaponDualRoom1 = 24;
return 1;
}
else if(DualRoom2 == -1)
{
SetTimerEx("inventationremove", 30000, 0, "i", playerid);
format(string, sizeof(string), "%s has sent you a 1 vs. 1 duel with a desert eagle for $%d, /acceptduel or /declineduel", sendername, price);
SendClientMessage(giveplayerid, GREEN, string);
format(string, sizeof(string), "you sent %s a 1 vs. 1 duel with a desert eagle for $%d", giveplayername, price);
SendClientMessage(playerid, GREEN, string);
InventationSent[playerid] = giveplayerid;
Inventation[giveplayerid] = playerid;
DualRoom2price = price;
DualRoom2 = playerid;
WeaponDualRoom2 = 24;
return 1;
}
else if(DualRoom3 == -1)
{
SetTimerEx("inventationremove", 30000, 0, "i", playerid);
format(string, sizeof(string), "%s has sent you a 1 vs. 1 duel with a desert eagle for $%d, /acceptduel or /declineduel", sendername, price);
SendClientMessage(giveplayerid, GREEN, string);
format(string, sizeof(string), "you sent %s a 1 vs. 1 duel with a desert eagle for $%d", giveplayername, price);
SendClientMessage(playerid, GREEN, string);
InventationSent[playerid] = giveplayerid;
Inventation[giveplayerid] = playerid;
DualRoom3price = price;
DualRoom3 = playerid;
WeaponDualRoom3 = 24;
return 1;
}
else if(DualRoom4 == -1)
{
SetTimerEx("inventationremove", 30000, 0, "i", playerid);
format(string, sizeof(string), "%s has sent you a 1 vs. 1 duel with a desert eagle for $%d, /acceptduel or /declineduel", sendername, price);
SendClientMessage(giveplayerid, GREEN, string);
format(string, sizeof(string), "you sent %s a 1 vs. 1 duel with a desert eagle for $%d", giveplayername, price);
SendClientMessage(playerid, GREEN, string);
InventationSent[playerid] = giveplayerid;
Inventation[giveplayerid] = playerid;
DualRoom4price = price;
DualRoom4 = playerid;
WeaponDualRoom4 = 24;
return 1;
}
else return SendClientMessage(playerid, RED, "there are no dual rooms free, wait till a dual ends");
}
else return SendClientMessage(playerid, RED, "This player is already in a dual");
}
else return SendClientMessage(playerid, RED, "you are still in a dual, end it first");
}
else return SendClientMessage(playerid, RED, "You already sent an inventation, wait 30 seconds or wait till the other player declines");
}
else return SendClientMessage(playerid, RED, "This player already got an inventation");
}
else return SendClientMessage(playerid, RED, "You can't afford the dual fee");
}
if(strcmp("mp5", weapon, true, 3) == 0)
{
if(GetPlayerMoney(playerid) >= price)
{
if(Inventation[giveplayerid] == -1)
{
if(InventationSent[playerid] == -1)
{
if(InDual[playerid] == 0)
{
if(InDual[giveplayerid] == 0)
{
if(DualRoom1 == -1)
{
SetTimerEx("inventationremove", 30000, 0, "i", playerid);
format(string, sizeof(string), "%s has sent you a 1 vs. 1 duel with a desert eagle for $%d, /acceptduel or /declineduel", sendername, price);
SendClientMessage(giveplayerid, GREEN, string);
format(string, sizeof(string), "you sent %s a 1 vs. 1 duel with a desert eagle for $%d", giveplayername, price);
SendClientMessage(playerid, GREEN, string);
InventationSent[playerid] = giveplayerid;
Inventation[giveplayerid] = playerid;
Inventationprice[giveplayerid] = price;
DualRoom1price = price;
DualRoom1 = playerid;
WeaponDualRoom1 = 29;
return 1;
}
else if(DualRoom2 == -1)
{
SetTimerEx("inventationremove", 30000, 0, "i", playerid);
format(string, sizeof(string), "%s has sent you a 1 vs. 1 duel with a desert eagle for $%d, /acceptduel or /declineduel", sendername, price);
SendClientMessage(giveplayerid, GREEN, string);
format(string, sizeof(string), "you sent %s a 1 vs. 1 duel with a desert eagle for $%d", giveplayername, price);
SendClientMessage(playerid, GREEN, string);
InventationSent[playerid] = giveplayerid;
Inventation[giveplayerid] = playerid;
DualRoom2price = price;
DualRoom2 = playerid;
WeaponDualRoom2 = 29;
return 1;
}
else if(DualRoom3 == -1)
{
SetTimerEx("inventationremove", 30000, 0, "i", playerid);
format(string, sizeof(string), "%s has sent you a 1 vs. 1 duel with a desert eagle for $%d, /acceptduel or /declineduel", sendername, price);
SendClientMessage(giveplayerid, GREEN, string);
format(string, sizeof(string), "you sent %s a 1 vs. 1 duel with a desert eagle for $%d", giveplayername, price);
SendClientMessage(playerid, GREEN, string);
InventationSent[playerid] = giveplayerid;
Inventation[giveplayerid] = playerid;
DualRoom3price = price;
DualRoom3 = playerid;
WeaponDualRoom3 = 29;
return 1;
}
else if(DualRoom4 == -1)
{
SetTimerEx("inventationremove", 30000, 0, "i", playerid);
format(string, sizeof(string), "%s has sent you a 1 vs. 1 duel with a desert eagle for $%d, /acceptduel or /declineduel", sendername, price);
SendClientMessage(giveplayerid, GREEN, string);
format(string, sizeof(string), "you sent %s a 1 vs. 1 duel with a desert eagle for $%d", giveplayername, price);
SendClientMessage(playerid, GREEN, string);
InventationSent[playerid] = giveplayerid;
Inventation[giveplayerid] = playerid;
DualRoom4price = price;
DualRoom4 = playerid;
WeaponDualRoom4 = 29;
return 1;
}
else return SendClientMessage(playerid, RED, "there are no dual rooms free, wait till a dual ends");
}
else return SendClientMessage(playerid, RED, "This player is already in a dual");
}
else return SendClientMessage(playerid, RED, "you are still in a dual, end it first");
}
else return SendClientMessage(playerid, RED, "You already sent an inventation, wait 30 seconds or wait till the other player declines");
}
else return SendClientMessage(playerid, RED, "This player already got an inventation");
}
else return SendClientMessage(playerid, RED, "You can't afford the dual fee");
}
if(strcmp("chainsaw", weapon, true, 8) == 0)
{
if(GetPlayerMoney(playerid) >= price)
{
if(Inventation[giveplayerid] == -1)
{
if(InventationSent[playerid] == -1)
{
if(InDual[playerid] == 0)
{
if(InDual[giveplayerid] == 0)
{
if(DualRoom1 == -1)
{
SetTimerEx("inventationremove", 30000, 0, "i", playerid);
format(string, sizeof(string), "%s has sent you a 1 vs. 1 duel with a desert eagle for $%d, /acceptduel or /declineduel", sendername, price);
SendClientMessage(giveplayerid, GREEN, string);
format(string, sizeof(string), "you sent %s a 1 vs. 1 duel with a desert eagle for $%d", giveplayername, price);
SendClientMessage(playerid, GREEN, string);
InventationSent[playerid] = giveplayerid;
Inventation[giveplayerid] = playerid;
Inventationprice[giveplayerid] = price;
DualRoom1price = price;
DualRoom1 = playerid;
WeaponDualRoom1 = 9;
return 1;
}
else if(DualRoom2 == -1)
{
SetTimerEx("inventationremove", 30000, 0, "i", playerid);
format(string, sizeof(string), "%s has sent you a 1 vs. 1 duel with a desert eagle for $%d, /acceptduel or /declineduel", sendername, price);
SendClientMessage(giveplayerid, GREEN, string);
format(string, sizeof(string), "you sent %s a 1 vs. 1 duel with a desert eagle for $%d", giveplayername, price);
SendClientMessage(playerid, GREEN, string);
InventationSent[playerid] = giveplayerid;
Inventation[giveplayerid] = playerid;
DualRoom2price = price;
DualRoom2 = playerid;
WeaponDualRoom2 = 9;
return 1;
}
else if(DualRoom3 == -1)
{
SetTimerEx("inventationremove", 30000, 0, "i", playerid);
format(string, sizeof(string), "%s has sent you a 1 vs. 1 duel with a desert eagle for $%d, /acceptduel or /declineduel", sendername, price);
SendClientMessage(giveplayerid, GREEN, string);
format(string, sizeof(string), "you sent %s a 1 vs. 1 duel with a desert eagle for $%d", giveplayername, price);
SendClientMessage(playerid, GREEN, string);
InventationSent[playerid] = giveplayerid;
Inventation[giveplayerid] = playerid;
DualRoom3price = price;
DualRoom3 = playerid;
WeaponDualRoom3 = 9;
return 1;
}
else if(DualRoom4 == -1)
{
SetTimerEx("inventationremove", 30000, 0, "i", playerid);
format(string, sizeof(string), "%s has sent you a 1 vs. 1 duel with a desert eagle for $%d, /acceptduel or /declineduel", sendername, price);
SendClientMessage(giveplayerid, GREEN, string);
format(string, sizeof(string), "you sent %s a 1 vs. 1 duel with a desert eagle for $%d", giveplayername, price);
SendClientMessage(playerid, GREEN, string);
InventationSent[playerid] = giveplayerid;
Inventation[giveplayerid] = playerid;
DualRoom4price = price;
DualRoom4 = playerid;
WeaponDualRoom4 = 9;
return 1;
}
else return SendClientMessage(playerid, RED, "there are no dual rooms free, wait till a dual ends");
}
else return SendClientMessage(playerid, RED, "This player is already in a dual");
}
else return SendClientMessage(playerid, RED, "you are still in a dual, end it first");
}
else return SendClientMessage(playerid, RED, "You already sent an inventation, wait 30 seconds or wait till the other player declines");
}
else return SendClientMessage(playerid, RED, "This player already got an inventation");
}
else return SendClientMessage(playerid, RED, "You can't afford the dual fee");
}
if(strcmp("silpist", weapon, true, 7) == 0)
{
if(GetPlayerMoney(playerid) >= price)
{
if(Inventation[giveplayerid] == -1)
{
if(InventationSent[playerid] == -1)
{
if(InDual[playerid] == 0)
{
if(InDual[giveplayerid] == 0)
{
SetTimerEx("inventationremove", 30000, 0, "i", playerid);
if(DualRoom1 == -1)
{
SetTimerEx("inventationremove", 30000, 0, "i", playerid);
format(string, sizeof(string), "%s has sent you a 1 vs. 1 duel with a desert eagle for $%d, /acceptduel or /declineduel", sendername, price);
SendClientMessage(giveplayerid, GREEN, string);
format(string, sizeof(string), "you sent %s a 1 vs. 1 duel with a desert eagle for $%d", giveplayername, price);
SendClientMessage(playerid, GREEN, string);
InventationSent[playerid] = giveplayerid;
Inventation[giveplayerid] = playerid;
Inventationprice[giveplayerid] = price;
DualRoom1price = price;
DualRoom1 = playerid;
WeaponDualRoom1 = 23;
return 1;
}
else if(DualRoom2 == -1)
{
SetTimerEx("inventationremove", 30000, 0, "i", playerid);
format(string, sizeof(string), "%s has sent you a 1 vs. 1 duel with a desert eagle for $%d, /acceptduel or /declineduel", sendername, price);
SendClientMessage(giveplayerid, GREEN, string);
format(string, sizeof(string), "you sent %s a 1 vs. 1 duel with a desert eagle for $%d", giveplayername, price);
SendClientMessage(playerid, GREEN, string);
InventationSent[playerid] = giveplayerid;
Inventation[giveplayerid] = playerid;
DualRoom2price = price;
DualRoom2 = playerid;
WeaponDualRoom2 = 23;
return 1;
}
else if(DualRoom3 == -1)
{
SetTimerEx("inventationremove", 30000, 0, "i", playerid);
format(string, sizeof(string), "%s has sent you a 1 vs. 1 duel with a desert eagle for $%d, /acceptduel or /declineduel", sendername, price);
SendClientMessage(giveplayerid, GREEN, string);
format(string, sizeof(string), "you sent %s a 1 vs. 1 duel with a desert eagle for $%d", giveplayername, price);
SendClientMessage(playerid, GREEN, string);
InventationSent[playerid] = giveplayerid;
Inventation[giveplayerid] = playerid;
DualRoom3price = price;
DualRoom3 = playerid;
WeaponDualRoom3 = 23;
return 1;
}
else if(DualRoom4 == -1)
{
SetTimerEx("inventationremove", 30000, 0, "i", playerid);
format(string, sizeof(string), "%s has sent you a 1 vs. 1 duel with a desert eagle for $%d, /acceptduel or /declineduel", sendername, price);
SendClientMessage(giveplayerid, GREEN, string);
format(string, sizeof(string), "you sent %s a 1 vs. 1 duel with a desert eagle for $%d", giveplayername, price);
SendClientMessage(playerid, GREEN, string);
InventationSent[playerid] = giveplayerid;
Inventation[giveplayerid] = playerid;
DualRoom4price = price;
DualRoom4 = playerid;
WeaponDualRoom4 = 23;
return 1;
}
else return SendClientMessage(playerid, RED, "there are no dual rooms free, wait till a dual ends");
}
else return SendClientMessage(playerid, RED, "This player is already in a dual");
}
else return SendClientMessage(playerid, RED, "you are still in a dual, end it first");
}
else return SendClientMessage(playerid, RED, "You already sent an inventation, wait 30 seconds or wait till the other player declines");
}
else return SendClientMessage(playerid, RED, "This player already got an inventation");
}
else return SendClientMessage(playerid, RED, "You can't afford the dual fee");
}
if(strcmp("combatsg", weapon, true, 8) == 0)
{
if(GetPlayerMoney(playerid) >= price)
{
if(Inventation[giveplayerid] == -1)
{
if(InventationSent[playerid] == -1)
{
if(InDual[playerid] == 0)
{
if(InDual[giveplayerid] == 0)
{
if(DualRoom1 == -1)
{
SetTimerEx("inventationremove", 30000, 0, "i", playerid);
format(string, sizeof(string), "%s has sent you a 1 vs. 1 duel with a desert eagle for $%d, /acceptduel or /declineduel", sendername, price);
SendClientMessage(giveplayerid, GREEN, string);
format(string, sizeof(string), "you sent %s a 1 vs. 1 duel with a desert eagle for $%d", giveplayername, price);
SendClientMessage(playerid, GREEN, string);
InventationSent[playerid] = giveplayerid;
Inventation[giveplayerid] = playerid;
Inventationprice[giveplayerid] = price;
DualRoom1price = price;
DualRoom1 = playerid;
WeaponDualRoom1 = 27;
return 1;
}
else if(DualRoom2 == -1)
{
SetTimerEx("inventationremove", 30000, 0, "i", playerid);
format(string, sizeof(string), "%s has sent you a 1 vs. 1 duel with a desert eagle for $%d, /acceptduel or /declineduel", sendername, price);
SendClientMessage(giveplayerid, GREEN, string);
format(string, sizeof(string), "you sent %s a 1 vs. 1 duel with a desert eagle for $%d", giveplayername, price);
SendClientMessage(playerid, GREEN, string);
InventationSent[playerid] = giveplayerid;
Inventation[giveplayerid] = playerid;
DualRoom2price = price;
DualRoom2 = playerid;
WeaponDualRoom2 = 27;
return 1;
}
else if(DualRoom3 == -1)
{
SetTimerEx("inventationremove", 30000, 0, "i", playerid);
format(string, sizeof(string), "%s has sent you a 1 vs. 1 duel with a desert eagle for $%d, /acceptduel or /declineduel", sendername, price);
SendClientMessage(giveplayerid, GREEN, string);
format(string, sizeof(string), "you sent %s a 1 vs. 1 duel with a desert eagle for $%d", giveplayername, price);
SendClientMessage(playerid, GREEN, string);
InventationSent[playerid] = giveplayerid;
Inventation[giveplayerid] = playerid;
DualRoom3price = price;
DualRoom3 = playerid;
WeaponDualRoom3 = 27;
return 1;
}
else if(DualRoom4 == -1)
{
SetTimerEx("inventationremove", 30000, 0, "i", playerid);
format(string, sizeof(string), "%s has sent you a 1 vs. 1 duel with a desert eagle for $%d, /acceptduel or /declineduel", sendername, price);
SendClientMessage(giveplayerid, GREEN, string);
format(string, sizeof(string), "you sent %s a 1 vs. 1 duel with a desert eagle for $%d", giveplayername, price);
SendClientMessage(playerid, GREEN, string);
InventationSent[playerid] = giveplayerid;
Inventation[giveplayerid] = playerid;
DualRoom4price = price;
DualRoom4 = playerid;
WeaponDualRoom4 = 27;
return 1;
}
else return SendClientMessage(playerid, RED, "there are no dual rooms free, wait till a dual ends");
}
else return SendClientMessage(playerid, RED, "This player is already in a dual");
}
else return SendClientMessage(playerid, RED, "you are still in a dual, end it first");
}
else return SendClientMessage(playerid, RED, "You already sent an inventation, wait 30 seconds or wait till the other player declines");
}
else return SendClientMessage(playerid, RED, "This player already got an inventation");
}
else return SendClientMessage(playerid, RED, "You can't afford the dual fee");
}
if(strcmp("shotgun", weapon, true, 7) == 0)
{
if(GetPlayerMoney(playerid) >= price)
{
if(Inventation[giveplayerid] == -1)
{
if(InventationSent[playerid] == -1)
{
if(InDual[playerid] == 0)
{
if(InDual[giveplayerid] == 0)
{
if(DualRoom1 == -1)
{
SetTimerEx("inventationremove", 30000, 0, "i", playerid);
format(string, sizeof(string), "%s has sent you a 1 vs. 1 duel with a desert eagle for $%d, /acceptduel or /declineduel", sendername, price);
SendClientMessage(giveplayerid, GREEN, string);
format(string, sizeof(string), "you sent %s a 1 vs. 1 duel with a desert eagle for $%d", giveplayername, price);
SendClientMessage(playerid, GREEN, string);
InventationSent[playerid] = giveplayerid;
Inventation[giveplayerid] = playerid;
Inventationprice[giveplayerid] = price;
DualRoom1price = price;
DualRoom1 = playerid;
WeaponDualRoom1 = 25;
return 1;
}
else if(DualRoom2 == -1)
{
SetTimerEx("inventationremove", 30000, 0, "i", playerid);
format(string, sizeof(string), "%s has sent you a 1 vs. 1 duel with a desert eagle for $%d, /acceptduel or /declineduel", sendername, price);
SendClientMessage(giveplayerid, GREEN, string);
format(string, sizeof(string), "you sent %s a 1 vs. 1 duel with a desert eagle for $%d", giveplayername, price);
SendClientMessage(playerid, GREEN, string);
InventationSent[playerid] = giveplayerid;
Inventation[giveplayerid] = playerid;
DualRoom2price = price;
DualRoom2 = playerid;
WeaponDualRoom2 = 25;
return 1;
}
else if(DualRoom3 == -1)
{
SetTimerEx("inventationremove", 30000, 0, "i", playerid);
format(string, sizeof(string), "%s has sent you a 1 vs. 1 duel with a desert eagle for $%d, /acceptduel or /declineduel", sendername, price);
SendClientMessage(giveplayerid, GREEN, string);
format(string, sizeof(string), "you sent %s a 1 vs. 1 duel with a desert eagle for $%d", giveplayername, price);
SendClientMessage(playerid, GREEN, string);
InventationSent[playerid] = giveplayerid;
Inventation[giveplayerid] = playerid;
DualRoom3price = price;
DualRoom3 = playerid;
WeaponDualRoom3 = 25;
return 1;
}
else if(DualRoom4 == -1)
{
SetTimerEx("inventationremove", 30000, 0, "i", playerid);
format(string, sizeof(string), "%s has sent you a 1 vs. 1 duel with a desert eagle for $%d, /acceptduel or /declineduel", sendername, price);
SendClientMessage(giveplayerid, GREEN, string);
format(string, sizeof(string), "you sent %s a 1 vs. 1 duel with a desert eagle for $%d", giveplayername, price);
SendClientMessage(playerid, GREEN, string);
InventationSent[playerid] = giveplayerid;
Inventation[giveplayerid] = playerid;
DualRoom4price = price;
DualRoom4 = playerid;
WeaponDualRoom4 = 25;
return 1;
}
else return SendClientMessage(playerid, RED, "there are no duel rooms free, wait till a duel ends");
}
else return SendClientMessage(playerid, RED, "This player is already in a duel");
}
else return SendClientMessage(playerid, RED, "you are still in a duel, end it first");
}
else return SendClientMessage(playerid, RED, "You already sent an inventation, wait 30 seconds or wait till the other player declines");
}
else return SendClientMessage(playerid, RED, "This player already got an inventation");
}
else return SendClientMessage(playerid, RED, "You can't afford the duel fee");
}
else return SendClientMessage(playerid, COLOR_YELLOW, "Right Usage: /duel [playerid] [weapon] [amount]");
}
else return SendClientMessage(playerid, RED, "You cant duel yourself");
}
}
how to make this command without sscanf ?
pawn Код:
if (sscanf(params, "isi", giveplayerid,weapon,price))