Here is a quick duel system I made, let me know if there is any trouble.
pawn Код:
enum duels
{
induel,
weapname,
weapid
}
new duelinfo[MAX_PLAYERS][duels];
new invite[MAX_PLAYERS],
inviter[MAX_PLAYERS],
DuelSender[MAX_PLAYERS],
DuelReciever[MAX_PLAYERS];
CMD:duel(playerid, params[])
{
new target, weap1[45], weap2[45], weaponid = -1, weaponid2 = -1;
if(sscanf(params, "us[45]s[45]", target, weap1, weap2)) return SendClientMessage(playerid, -1, "USAGE: /duel <username/id> <weapon 1 name> <weapon 2 name>");
if(target == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1, "Player is offline");
if(target == playerid) return SendClientMessage(playerid, -1, "You cannot duel yourself");
if(duelinfo[playerid][induel] == 1) return SendClientMessage(playerid, -1, "You are already in a duel");
if(duelinfo[target][induel] == 1) return SendClientMessage(playerid, -1, "Player is already in a duel");
if(invite[target] == 1) return SendClientMessage(playerid, -1, "Player already has a duel invitation");
if(inviter[playerid] == 1) return SendClientMessage(playerid, -1, "You already invited a player, please wait till it's rejected or accepted!");
if(StringNumeric(weap1) && StringNumeric(weap2))
{
weaponid = strval(weap1);
weaponid2 = strval(weap2);
}
else
{
weaponid = CheckWeaponID(weap1);
weaponid2 = CheckWeaponID(weap2);
}
DuelSender[target] = playerid;
duelinfo[playerid][weapid] = weaponid;
duelinfo[playerid][weapname] = weap1;
duelinfo[user][weapid] = weaponid2;
duelinfo[user][weapname] = weap2;
invite[target] = 1;
inviter[playerid] = 1;
DuelReciever[playerid] = target;
// Send a message that he sent a request to target
// Send a message to target that he recieved an invitation
return 1;
}
CMD:acceptduel(playerid, params[])
{
if(invite[playerid] == 1)
{
new user = DuelSender[playerid];
ResetPlayerWeapons(user);
RemovePlayerFromVehicle(user);
SetPlayerArmour(user, 0);
SetPlayerHealth(user, 100);
SetPlayerVirtualWorld(user, 100); // Change the world
SetPlayerPos(user, xxx, xxx, xxx); // Change to your position
GivePlayerWeapon(user, duelinfo[playerid][weapid], 500);
duelinfo[user][induel] = 1;
inviter[user] = 0;
ResetPlayerWeapons(playerid);
RemovePlayerFromVehicle(playerid);
SetPlayerArmour(playerid, 0);
SetPlayerHealth(playerid, 100);
SetPlayerVirtualWorld(playerid, 100); // Same as before
GivePlayerWeapon(playerid, duelinfo[user][weapid], 500);
SetPlayerPos(playerid, xxx, xxx, xxx); // Same as before
duelinfo[playerid][induel] = 1;
invite[playerid] = 0;
}
else return SendClientMessage(playerid, -1, "You didn't recieve any duel request");
return 1;
}
CMD:declineduel(playerid, params[])
{
if(invite[playerid] == 1)
{
new user = DuelSender[playerid];
invite[playerid] = 0;
inviter[user] = 0;
// Send the messagess
}
else return SendClientMessage(playerid, -1, "You didn't recieve any duel request");
return 1;
}
CMD:cancelrequest(playerid, params[])
{
if(inviter[playerid] == 1)
{
new user = DuelReciever[playerid];
inviter[playerid] = 0;
invite[user] = 0;
// Send the messages
}
else return SendClientMessage(playerid, -1, "You didn't send any duel request");
return 1;
}