Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <zcmd>
- #include <sscanf>
- #define FILTERSCRIPT
- #define COLOR_MAGENTA 0xFF00FFFF
- #define COLOR_AQUA 0xF0F8FFAA
- #define COLOR_GREEN 0x33AA33AA
- #define DIALOG_DUELWEAPONS 429
- #define DIALOG_DUELWEAPONSTWO 430
- #define DIALOG_DUELROUNDS 431
- forward DuelStart(playerid);
- forward DuelTimer(playerid);
- forward DelayedDuelSpawn(playerid);
- forward DuelbetEnd(playerid);
- forward UnnormalDuelend(playerid);
- public OnFilterScriptInit()
- {
- print("--- Duelsystem ---");
- CreateObject(5791, 2807.30005, -1763.09998, 34.2, 0, 0, 0);
- CreateObject(3452, 3394.56006, -1749.20007, 14, 0, 0, 90);
- CreateObject(13607, 3358.3994, -1750, 11.8, 0, 0, 0);
- CreateObject(3452, 3358, -1714.42004, 14, 0, 0, 179.995);
- CreateObject(3453, 3388.2002, -1719.9004, 14, 0, 0, 90);
- CreateObject(3453, 3328.69995, -1720.80005, 14, 0, 0, 180);
- CreateObject(3453, 3389.0801, -1779.3994, 14, 0, 0, 0);
- CreateObject(3452, 3359.77002, -1785.77002, 14, 0, 0, 0);
- CreateObject(3452, 3323.21997, -1751.04004, 14, 0, 0, 270);
- CreateObject(3453, 3329.5898, -1780.2988, 14, 0, 0, 270);
- CreateObject(8572, 3376.0234, -1724.7446, 10.1506, 0, 0, 0);
- CreateObject(8572, 3384.2329, -1768.0134, 10.1506, 0, 0, 270);
- CreateObject(8572, 3340.9165, -1775.4479, 10.1598, 0, 0, 179.995);
- CreateObject(8572, 3333.5444, -1732.9769, 10.1506, 0, 0, 90);
- CreateObject(3095, 3342.2317, -1723.2845, 6.88609, 90, 0, 0);
- CreateObject(3095, 3351.2288, -1723.2832, 6.88609, 90, 0, 0);
- CreateObject(3095, 3360.2168, -1723.2844, 6.88609, 90, 0, 0);
- CreateObject(3095, 3369.2134, -1723.2875, 6.88609, 90, 0, 0);
- CreateObject(3095, 3375.531, -1723.2854, 6.88609, 90, 0, 0);
- CreateObject(3095, 3385.7004, -1733.4332, 6.88609, 90, 0, 270);
- CreateObject(3095, 3385.7007, -1742.4258, 6.88609, 90, 0, 269.995);
- CreateObject(3095, 3385.7019, -1751.4208, 6.88609, 90, 0, 269.995);
- CreateObject(3095, 3385.6987, -1760.411, 6.88609, 90, 0, 269.995);
- CreateObject(3095, 3385.7026, -1766.7291, 6.88609, 90, 0, 269.995);
- CreateObject(3095, 3375.5408, -1776.9016, 6.88609, 90, 0, 180);
- CreateObject(3095, 3375.541, -1776.9014, 6.88609, 90, 0, 179.995);
- CreateObject(3095, 3366.561, -1776.9048, 6.88609, 90, 0, 179.995);
- CreateObject(3095, 3357.593, -1776.901, 6.88609, 90, 0, 179.995);
- CreateObject(3095, 3348.6008, -1776.9082, 6.88609, 90, 0, 179.995);
- CreateObject(3095, 3342.2478, -1776.9099, 6.88609, 90, 0, 179.995);
- CreateObject(3095, 3332.0815, -1766.7762, 6.88609, 90, 0, 90);
- CreateObject(3095, 3332.084, -1757.7804, 6.88609, 90, 0, 90);
- CreateObject(3095, 3332.084, -1748.7902, 6.88609, 90, 0, 90);
- CreateObject(3095, 3332.0813, -1739.7958, 6.88609, 90, 0, 90);
- CreateObject(3095, 3332.0747, -1733.4602, 6.88609, 90, 0, 90);
- CreateObject(3095, 3383.7539, -1774.3701, 6.37089, 90, 0, 225);
- CreateObject(3095, 3384.5127, -1774.2695, 6.37089, 90, 0, 248);
- CreateObject(3095, 3382.7236, -1775.8574, 6.37089, 90, 0, 201.995);
- CreateObject(3095, 3333.9805, -1774.3906, 6.36629, 90, 0, 135);
- CreateObject(3095, 3335.4199, -1776.0186, 6.36629, 90, 0, 158);
- CreateObject(3095, 3332.8809, -1773.335, 6.36629, 90, 0, 111.995);
- CreateObject(3095, 3333.9707, -1725.9053, 6.37089, 90, 0, 44.995);
- CreateObject(3095, 3335.3193, -1724.2227, 6.37089, 90, 0, 21.995);
- CreateObject(3095, 3333.0635, -1726.5205, 6.37089, 90, 0, 66.995);
- CreateObject(3095, 3383.6084, -1725.66406, 6.37089, 90, 0, 315);
- CreateObject(3095, 3384.1719, -1725.2324, 6.37089, 90, 0, 293);
- CreateObject(3095, 3381.4678, -1723.8301, 6.37089, 90, 0, 338);
- CreateObject(2395, 3385.6082, -1770.8044, 10.89134, 0, 90, 248);
- CreateObject(2395, 3384.7749, -1772.9844, 10.89134, 0, 90, 225);
- CreateObject(2395, 3382.1633, -1775.7682, 10.89134, 0, 90, 202);
- CreateObject(2395, 3383.5215, -1774.2402, 10.89134, 0, 90, 225);
- CreateObject(2395, 3338.1655, -1776.8087, 10.89134, 0, 90, 158);
- CreateObject(2395, 3336.0039, -1775.9884, 10.89134, 0, 90, 135);
- CreateObject(2395, 3334.9548, -1774.9421, 10.89134, 0, 90, 135);
- CreateObject(2395, 3333.2173, -1773.3767, 10.89134, 0, 90, 112);
- CreateObject(2395, 3332.177, -1729.3234, 10.89134, 0, 90, 67);
- CreateObject(2395, 3333.0676, -1727.174, 10.89134, 0, 90, 45);
- CreateObject(2395, 3334.0354, -1726.2052, 10.89134, 0, 90, 45);
- CreateObject(2395, 3335.6382, -1724.4154, 10.89134, 0, 90, 22);
- CreateObject(2395, 3379.6348, -1723.3929, 10.89134, 0, 90, 338);
- CreateObject(2395, 3381.7717, -1724.2012, 10.89134, 0, 90, 315);
- CreateObject(2395, 3382.8872, -1725.3167, 10.89134, 0, 90, 314.995);
- CreateObject(2395, 3384.5247, -1726.7509, 10.89134, 0, 90, 293);
- return 1;
- }
- new Duel[MAX_PLAYERS],
- DuelEndTimer[MAX_PLAYERS],
- Duelmaker[MAX_PLAYERS],
- Duelopponent[MAX_PLAYERS],
- Gotrequest[MAX_PLAYERS],
- Maderequest[MAX_PLAYERS],
- Duelbet[MAX_PLAYERS],
- DuelbetPlayer[MAX_PLAYERS],
- DuelbetEnabled[MAX_PLAYERS],
- UnDuelend[MAX_PLAYERS],
- Duelrounds[MAX_PLAYERS],
- Duelwins[MAX_PLAYERS],
- Duelweap1[MAX_PLAYERS],
- Duelweap2[MAX_PLAYERS],
- bool:DuelToggle;
- //------------------------------------------------------------------------------
- CMD:duel(playerid,params[])
- {
- new PID;
- if(DuelToggle == true)return SendClientMessage(playerid,COLOR_GREEN,"SERVER: You're not allowed to use this command.");
- if(sscanf(params,"u",PID))return SendClientMessage(playerid,COLOR_GREEN,"/duel [id]");
- if(!IsPlayerConnected(PID)) return SendClientMessage(playerid,COLOR_GREEN,"SERVER: There is no player with this id.");
- if(Duel[playerid] >=1) return SendClientMessage(playerid,COLOR_GREEN,"SERVER: You're already in a duel.");
- {
- if(Duel[PID] >=1)
- {
- SendClientMessage(playerid,COLOR_MAGENTA,"* This player is already in a duel.");
- }
- else
- {
- if(PID == playerid) return SendClientMessage(playerid,COLOR_GREEN,"SERVER: You can't duel yourself.");
- Duelmaker[PID] = playerid;
- Duelopponent[playerid] = PID;
- Gotrequest[PID] = 1;
- Maderequest[playerid] = 1;
- ShowPlayerDialog(playerid, DIALOG_DUELWEAPONS, DIALOG_STYLE_LIST, "{FF00FF}First Duelweapon","{F0F8FF}Desert Eagle\n{F0F8FF}Shotgun\n{F0F8FF}Sawnoff Shotgun\n{F0F8FF}Combat Shotgun\n{F0F8FF}Micro SMG\n{F0F8FF}MP5\n{F0F8FF}AK-47\n{F0F8FF}M4\n{F0F8FF}Tec-9\n{F0F8FF}Country Rifle\n{F0F8FF}Sniper Rifle\n{F0F8FF}Fist\n{F0F8FF}Knife\n{F0F8FF}Katana\n{F0F8FF}Chainsaw\n{F0F8FF}Colt\n{F0F8FF}Silenced 9mm","Okey","");
- }
- }
- return 1;
- }
- CMD:accept(playerid,params[])
- {
- new PID = Duelmaker[playerid];
- if(Duel[playerid] ==0) return SendClientMessage(playerid,COLOR_MAGENTA,"* You're not invited for a duel.");
- if(Gotrequest[playerid]==1)
- if(IsPlayerConnected(PID))
- {
- if(Duel[PID] ==1)
- {
- new string[150],Weaponname[32],Weaponname2[32];
- ResetPlayerWeapons(PID);
- ResetPlayerWeapons(playerid);
- GetWeaponName(Duelweap1[PID],Weaponname,32);
- GetWeaponName(Duelweap2[PID],Weaponname2,32);
- format(string,sizeof(string),"DUEL: {F0F8FF}%s {FF00FF}vs {F0F8FF}%s. {FF00FF}Weapons: {F0F8FF}%s, %s {FF00FF}Rounds: {F0F8FF}%d",PlayerName(playerid),PlayerName(PID),Weaponname,Weaponname2,Duelrounds[PID]);
- SendClientMessageToAll(COLOR_MAGENTA,string);
- SendClientMessageToAll(COLOR_AQUA,"DUEL: You can use now /duelbet [id] [amount] for this duel.");
- SendClientMessage(PID,COLOR_MAGENTA,"* Your duelrequest has been accepted.");
- SendClientMessage(playerid,COLOR_MAGENTA,"* You accepted the duelrequest.");
- SetPlayerFacingAngle(PID,135);
- SetPlayerPos(PID,3374.6348,-1734.9648,9.2609);
- SetCameraBehindPlayer(PID);
- SetPlayerFacingAngle(playerid,-45);
- SetPlayerPos(playerid,3341.7039,-1766.2764,9.2609);
- SetCameraBehindPlayer(playerid);
- SetPlayerVirtualWorld(playerid,PID);
- SetPlayerVirtualWorld(PID,PID);
- Duel[PID] = 3;
- Duel[playerid] = 2;
- GivePlayerWeapon(PID,Duelweap1[PID],2000);
- GivePlayerWeapon(playerid,Duelweap1[playerid],2000);
- GivePlayerWeapon(PID,Duelweap2[PID],2000);
- GivePlayerWeapon(playerid,Duelweap2[playerid],2000);
- TogglePlayerControllable(PID,0);
- TogglePlayerControllable(playerid,0);
- SetPlayerArmour(PID,100);
- SetPlayerHealth(PID,100);
- SetPlayerArmour(playerid,100);
- SetPlayerHealth(playerid,100);
- SetTimerEx("DuelStart",5000,false,"i",PID);
- SetTimerEx("DuelStart",5000,false,"i",playerid);
- GameTextForPlayer(PID,"~g~Ready, Steady",5000,4);
- GameTextForPlayer(playerid,"~g~Ready, Steady",5000,4);
- DuelbetEnabled[PID] = 1;
- DuelbetEnabled[playerid] = 1;
- SetTimerEx("DuelbetEnd",10000,false,"i",PID);
- SetTimerEx("DuelbetEnd",10000,false,"i",playerid);
- KillTimer(DuelEndTimer[playerid]);
- KillTimer(DuelEndTimer[PID]);
- UnDuelend[PID] = SetTimerEx("UnnormalDuelend",80000,false,"i",PID);//Here you can change the time after which the duel
- UnDuelend[playerid] = SetTimerEx("UnnormalDuelend",80000,false,"i",playerid);//will end when noone was killed.(Or when one went afk)
- }
- }
- return 1;
- }
- CMD:cancel(playerid,params[])
- {
- new PID = Duelmaker[playerid];
- if(Duel[playerid] ==0) return SendClientMessage(playerid,COLOR_MAGENTA,"* You're not invited for a duel.");
- if(Gotrequest[playerid]==1)
- if(IsPlayerConnected(PID))
- {
- if(Duel[PID] ==1)
- {
- SendClientMessage(PID,COLOR_MAGENTA,"* Your duelrequest has been denied.");
- Duel[PID] = 0;
- SendClientMessage(playerid,COLOR_MAGENTA,"* You denied the duelrequest.");
- Duel[playerid] = 0;
- KillTimer(DuelEndTimer[playerid]);
- KillTimer(DuelEndTimer[PID]);
- }
- }
- return 1;
- }
- //------------------------------------------------------------------------------
- CMD:toggleduel(playerid,params[])
- {
- if(!IsPlayerAdmin(playerid))return SendClientMessage(playerid,COLOR_GREEN,"You are not allowed to use this command!");
- if(DuelToggle == false)
- {
- DuelToggle = true;
- SendClientMessage(playerid,COLOR_MAGENTA,"DUEL: You disabled the duelrequests.");
- }
- else if(DuelToggle == true)
- {
- DuelToggle = false;
- SendClientMessage(playerid,COLOR_MAGENTA,"DUEL: You enabled the duelrequests.");
- }
- return 1;
- }
- CMD:duellist(playerid,params[])
- {
- new count,string[160];
- SendClientMessage(playerid,COLOR_MAGENTA," --> Running Duels:");
- for(new i=0;i<MAX_PLAYERS;i++)
- if(IsPlayerConnected(i))
- {
- if(Duel[i] ==2)
- {
- new PID=Duelmaker[i],Weaponname[32],Weaponname2[32];
- GetWeaponName(Duelweap1[PID],Weaponname,32);
- GetWeaponName(Duelweap2[PID],Weaponname2,32);
- format(string,sizeof(string)," -> {F0F8FF}%s {FF00FF}vs {F0F8FF}%s{FF00FF} Weapons:{F0F8FF} %s, %s {FF00FF}Rounds:{F0F8FF} %i",PlayerName(i),PlayerName(PID),Weaponname,Weaponname2,Duelrounds[PID]);
- SendClientMessage(playerid,COLOR_MAGENTA,string);
- count++;
- }
- }
- if(count==0)
- {
- SendClientMessage(playerid,COLOR_AQUA,"* Currently there aren't any duels running.");
- }
- return 1;
- }
- CMD:duelhelp(playerid,params[])
- {
- SendClientMessage(playerid,COLOR_MAGENTA,"-------------------------------------------------------------------");
- SendClientMessage(playerid,COLOR_MAGENTA," --> Duelhelp:");
- SendClientMessage(playerid,COLOR_AQUA," * /duel [id] - /accept - /cancel");
- SendClientMessage(playerid,COLOR_AQUA," * /duelbet [id] [amount] - /duellist - /endduel - /toggleduel");
- SendClientMessage(playerid,COLOR_MAGENTA,"-------------------------------------------------------------------");
- return 1;
- }
- CMD:endduel(playerid,params[])
- {
- if(Duel[playerid] <2) return SendClientMessage(playerid,COLOR_GREEN,"SERVER: You're not in a duel.");
- if(Maderequest[playerid] == 1)
- {
- new string[150];
- new PID = Duelopponent[playerid];
- Duelrounds[playerid] = 0;
- Duelrounds[PID] = 0;
- Duel[playerid] = 0;
- Duel[PID] = 0;
- SetPlayerVirtualWorld(playerid,0);
- SetPlayerVirtualWorld(PID,0);
- Maderequest[playerid] = 0;
- SpawnPlayer(playerid);
- SpawnPlayer(PID);
- format(string,sizeof(string),"DUEL: {F0F8FF}%s {FF00FF}has won the duel against {F0F8FF}%s{FF00FF}. Reason: {F0F8FF}Cancelled by %s ",PlayerName(PID),PlayerName(playerid),PlayerName(playerid));
- SendClientMessageToAll(COLOR_MAGENTA,string);
- GivePlayerMoney(playerid, - 5000);//Here you can change the amount the /endduel cmd costs.
- KillTimer(UnDuelend[playerid]);
- KillTimer(UnDuelend[PID]);
- }
- else if(Gotrequest[playerid] == 1)
- {
- new string2[150];
- new PID = Duelmaker[playerid];
- Duelrounds[playerid] = 0;
- Duelrounds[PID] = 0;
- Duel[playerid] = 0;
- Duel[PID] = 0;
- SetPlayerVirtualWorld(playerid,0);
- SetPlayerVirtualWorld(PID,0);
- Gotrequest[playerid] = 0;
- SpawnPlayer(playerid);
- SpawnPlayer(PID);
- format(string2,sizeof(string2),"DUEL: {F0F8FF}%s {FF00FF}has won the duel against {F0F8FF}%s{FF00FF}. Reason: {F0F8FF}Cancelled by %s ",PlayerName(PID),PlayerName(playerid),PlayerName(playerid));
- SendClientMessageToAll(COLOR_MAGENTA,string2);
- GivePlayerMoney(playerid, - 5000);//Here you can change the amount the /endduel cmd costs.
- KillTimer(UnDuelend[playerid]);
- KillTimer(UnDuelend[PID]);
- }
- return 1;
- }
- //------------------------------------------------------------------------------
- CMD:duelbet(playerid,params[])
- {
- new PID,amount;
- if(sscanf(params,"ui",PID,amount)) return SendClientMessage(playerid,COLOR_GREEN,"/duelbet [id] [amount]");
- //if(Duel[playerid]>=1) return SendClientMessage(playerid,COLOR_GREEN,"SERVER: You can't bet while being in a duel.");
- if(Duel[PID]<2) return SendClientMessage(playerid,COLOR_GREEN,"SERVER: This player isn't in a duel.");
- if(DuelbetEnabled[PID] == 0) return SendClientMessage(playerid,COLOR_GREEN,"SERVER: The bet time for this duel is over.");
- if(amount<1000 || amount>100000) return SendClientMessage(playerid,COLOR_GREEN,"SERVER: The duelbet amount need to be between $1,000 and $100,000");
- if(GetPlayerMoney(playerid) < 0) return SendClientMessage(playerid,COLOR_GREEN,"SERVER: You don't have enough money.");
- if(Duelbet[playerid] > 0)
- {
- SendClientMessage(playerid,COLOR_GREEN,"SERVER: You already placed a bet on a duel.");
- }
- else
- {
- new string[128];
- DuelbetPlayer[playerid] = PID;
- Duelbet[playerid] = amount;
- GivePlayerMoney(playerid, - amount);
- format(string,sizeof(string),"* You have placed a bet of %i on %s.",amount,PlayerName(PID));
- SendClientMessage(playerid,COLOR_AQUA,string);
- }
- return 1;
- }
- //------------------------------------------------------------------------------
- public OnPlayerDisconnect(playerid)
- {
- if(Duel[playerid] >=2)
- {
- if(Maderequest[playerid] == 1)
- {
- new PID = Duelopponent[playerid];
- SpawnPlayer(PID);
- KillTimer(UnDuelend[playerid]);
- KillTimer(UnDuelend[PID]);
- Duel[PID] = 0;
- Duelrounds[PID] = 0;
- }
- else if(Gotrequest[playerid] == 1)
- {
- new PID = Duelmaker[playerid];
- SpawnPlayer(PID);
- KillTimer(UnDuelend[playerid]);
- KillTimer(UnDuelend[PID]);
- Duel[PID] = 0;
- Duelrounds[PID] = 0;
- }
- }
- DuelEndTimer[playerid] = 0;
- Duelmaker[playerid] = 0;
- Duelopponent[playerid] = 0;
- Gotrequest[playerid] = 0;
- Maderequest[playerid] = 0;
- Duelbet[playerid] = 0;
- DuelbetPlayer[playerid] = 0;
- DuelbetEnabled[playerid] = 0;
- Duel[playerid] = 0;
- Duelrounds[playerid] = 0;
- Duelweap1[playerid] = 0;
- Duelweap2[playerid] = 0;
- return 1;
- }
- //------------------------------------------------------------------------------
- public DelayedDuelSpawn(playerid)
- {
- if(Maderequest[playerid] == 1)
- {
- new string[150],Weaponname[32],Weaponname2[32];
- new PID = Duelopponent[playerid];
- ResetPlayerWeapons(PID);
- ResetPlayerWeapons(playerid);
- GetWeaponName(Duelweap1[playerid],Weaponname,32);
- GetWeaponName(Duelweap2[playerid],Weaponname2,32);
- format(string,sizeof(string),"DUEL: {F0F8FF}%s {FF00FF}vs {F0F8FF}%s. {FF00FF}Weapons: {F0F8FF}%s, %s {FF00FF}Round: {F0F8FF}%i",PlayerName(playerid),PlayerName(PID),Weaponname,Weaponname2,Duelrounds[playerid]);
- SendClientMessageToAll(COLOR_MAGENTA,string);
- SendClientMessageToAll(COLOR_AQUA,"DUEL: You can use now /duelbet [id] [amount] for this duel.");
- SetPlayerFacingAngle(PID,135);
- SetPlayerPos(PID,3374.6348,-1734.9648,9.2609);
- SetCameraBehindPlayer(PID);
- SetPlayerFacingAngle(playerid,-45);
- SetPlayerPos(playerid,3341.7039,-1766.2764,9.2609);
- SetCameraBehindPlayer(playerid);
- SetPlayerVirtualWorld(playerid,PID);
- SetPlayerVirtualWorld(PID,PID);
- GivePlayerWeapon(PID,Duelweap1[PID],2000);
- GivePlayerWeapon(playerid,Duelweap1[playerid],2000);
- GivePlayerWeapon(PID,Duelweap2[PID],2000);
- GivePlayerWeapon(playerid,Duelweap2[playerid],2000);
- TogglePlayerControllable(PID,0);
- TogglePlayerControllable(playerid,0);
- SetPlayerArmour(PID,100);
- SetPlayerHealth(PID,100);
- SetPlayerArmour(playerid,100);
- SetPlayerHealth(playerid,100);
- SetTimerEx("DuelStart",5000,false,"i",PID);
- SetTimerEx("DuelStart",5000,false,"i",playerid);
- GameTextForPlayer(PID,"~g~Ready, Steady",5000,4);
- GameTextForPlayer(playerid,"~g~Ready, Steady",5000,4);
- DuelbetEnabled[PID] = 1;
- DuelbetEnabled[playerid] = 1;
- SetTimerEx("DuelbetEnd",10000,false,"i",PID);
- SetTimerEx("DuelbetEnd",10000,false,"i",playerid);
- UnDuelend[PID] = SetTimerEx("UnnormalDuelend",80000,false,"i",PID);//Here you can change the time after which the duel
- UnDuelend[playerid] = SetTimerEx("UnnormalDuelend",80000,false,"i",playerid);//will end when noone was killed.(Or when one went afk)
- }
- else if(Gotrequest[playerid] == 1)
- {
- new string[150],Weaponname[32],Weaponname2[32];
- new PID = Duelmaker[playerid];
- ResetPlayerWeapons(PID);
- ResetPlayerWeapons(playerid);
- GetWeaponName(Duelweap1[playerid],Weaponname,32);
- GetWeaponName(Duelweap2[playerid],Weaponname2,32);
- format(string,sizeof(string),"DUEL: {F0F8FF}%s {FF00FF}vs {F0F8FF}%s. {FF00FF}Weapons: {F0F8FF}%s, %s {FF00FF}Round: {F0F8FF}%i",PlayerName(playerid),PlayerName(PID),Weaponname,Weaponname2,Duelrounds[playerid]);
- SendClientMessageToAll(COLOR_MAGENTA,string);
- SendClientMessageToAll(COLOR_AQUA,"DUEL: You can use now /duelbet [id] [amount] for this duel.");
- SetPlayerFacingAngle(PID,135);
- SetPlayerPos(PID,3374.6348,-1734.9648,9.2609);
- SetCameraBehindPlayer(PID);
- SetPlayerFacingAngle(playerid,-45);
- SetPlayerPos(playerid,3341.7039,-1766.2764,9.2609);
- SetCameraBehindPlayer(playerid);
- SetPlayerVirtualWorld(playerid,PID);
- SetPlayerVirtualWorld(PID,PID);
- GivePlayerWeapon(PID,Duelweap1[PID],2000);
- GivePlayerWeapon(playerid,Duelweap1[playerid],2000);
- GivePlayerWeapon(PID,Duelweap2[PID],2000);
- GivePlayerWeapon(playerid,Duelweap2[playerid],2000);
- TogglePlayerControllable(PID,0);
- TogglePlayerControllable(playerid,0);
- SetPlayerArmour(PID,100);
- SetPlayerHealth(PID,100);
- SetPlayerArmour(playerid,100);
- SetPlayerHealth(playerid,100);
- SetTimerEx("DuelStart",5000,false,"i",PID);
- SetTimerEx("DuelStart",5000,false,"i",playerid);
- GameTextForPlayer(PID,"~g~Ready, Steady",5000,4);
- GameTextForPlayer(playerid,"~g~Ready, Steady",5000,4);
- DuelbetEnabled[PID] = 1;
- DuelbetEnabled[playerid] = 1;
- SetTimerEx("DuelbetEnd",10000,false,"i",PID);
- SetTimerEx("DuelbetEnd",10000,false,"i",playerid);
- UnDuelend[PID] = SetTimerEx("UnnormalDuelend",80000,false,"i",PID);//Here you can change the time after which the duel
- UnDuelend[playerid] = SetTimerEx("UnnormalDuelend",80000,false,"i",playerid);//will end when noone was killed.(Or when one went afk)
- }
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- if(Duel[playerid] >=2)
- {
- if(Duelrounds[playerid] >0)
- {
- SetTimerEx("DelayedDuelSpawn",2000,false,"i",playerid);//Change the "2000" to the spawndelaytime you want. I recommend 2 seconds as a minimum.
- }
- }
- return 1;
- }
- //------------------------------------------------------------------------------
- public OnPlayerDeath(playerid, killerid, reason)
- {
- if(Duel[killerid] >=2 && Duel[playerid] >=2)
- {
- if(Duelrounds[playerid] <=1)
- {
- if(Duel[playerid] >=2)
- {
- Duel[playerid] = 0;
- SetPlayerVirtualWorld(playerid,0);
- Gotrequest[playerid] = 0;
- Maderequest[playerid] = 0;
- KillTimer(UnDuelend[playerid]);
- }
- }
- if(Duelrounds[playerid] >1)
- {
- Duelrounds[playerid] -= 1;
- KillTimer(UnDuelend[playerid]);
- }
- //Killerid
- if(Duelrounds[killerid] <=1)
- {
- if(Duel[killerid] >=2)
- {
- Gotrequest[killerid] = 0;
- Maderequest[killerid] = 0;
- Duelwins[killerid] += 1;
- SetPlayerVirtualWorld(killerid,0);
- Duel[killerid] = 0;
- new string[160],string2[128];
- new Weaponname[32],Weaponname2[32];
- GetWeaponName(Duelweap1[playerid],Weaponname,32);
- GetWeaponName(Duelweap2[playerid],Weaponname2,32);
- format(string,sizeof(string),"DUEL: {F0F8FF}%s {FF00FF}has won the last round against {F0F8FF}%s.{FF00FF} Weapons: {F0F8FF}%s, %s",PlayerName(killerid),PlayerName(playerid),Weaponname,Weaponname2);
- format(string2,sizeof(string2),"-> Final Result: %s {F0F8FF}%i:%i {FF00FF}%s",PlayerName(killerid),Duelwins[killerid],Duelwins[playerid],PlayerName(playerid));
- SendClientMessageToAll(COLOR_MAGENTA,string);
- SendClientMessageToAll(COLOR_MAGENTA,string2);
- SendClientMessage(killerid,COLOR_AQUA,"* You won the last round and received a reward. Congratulation.");
- GivePlayerMoney(killerid,5000);//This amount will the duelwinner receive. Change it to your prefered amount.
- SpawnPlayer(killerid);
- KillTimer(UnDuelend[killerid]);
- }
- }
- if(Duelrounds[killerid] >1)
- {
- new string[160];
- Duelwins[killerid] += 1;
- Duelrounds[killerid] -= 1;
- new Weaponname[32],Weaponname2[32];
- GetWeaponName(Duelweap1[playerid],Weaponname,32);
- GetWeaponName(Duelweap2[playerid],Weaponname2,32);
- format(string,sizeof(string),"DUEL: {F0F8FF}%s {FF00FF}has won the duel against {F0F8FF}%s.{FF00FF} Weapons: {F0F8FF}%s, %s",PlayerName(killerid),PlayerName(playerid),Weaponname,Weaponname2);
- SendClientMessageToAll(COLOR_MAGENTA,string);
- SendClientMessage(killerid,COLOR_AQUA,"* You won this round and received a reward. Congratulation.");
- GivePlayerMoney(killerid,5000);//Same like above. This is the reward the duelwinner will receive.
- KillTimer(UnDuelend[killerid]);
- }
- for(new i = 0; i < MAX_PLAYERS; i++)
- {
- if(Duelbet[i]>0)
- {
- if(DuelbetPlayer[i] == killerid)
- {
- new string[128];
- format(string,sizeof(string),"* You won %i from your duelbet.",Duelbet[i] * 2);
- SendClientMessage(i,COLOR_AQUA,string);
- GivePlayerMoney(i,Duelbet[i] * 2);
- Duelbet[i] = 0;
- }
- else
- {
- SendClientMessage(i,COLOR_AQUA,"* Your duelbet were wrong. Good luck next time.");
- Duelbet[i] = 0;
- }
- }
- }
- }
- if(Duel[killerid] >=2 && Duel[playerid] <2)
- {
- if(Gotrequest[killerid] == 1)
- {
- new PID = Duelmaker[killerid];
- Gotrequest[killerid] = 0;
- Maderequest[PID] = 0;
- SetPlayerVirtualWorld(killerid,0);
- Duel[killerid] = 0;
- Duelrounds[killerid] = 0;
- SetPlayerVirtualWorld(PID,0);
- Duel[PID] = 0;
- Duelrounds[PID] = 0;
- SendClientMessage(killerid,COLOR_MAGENTA,"* The duel ended due to some issues.");
- SendClientMessage(PID,COLOR_MAGENTA,"* The duel ended due to some issues.");
- SpawnPlayer(killerid);
- SpawnPlayer(PID);
- KillTimer(UnDuelend[killerid]);
- KillTimer(UnDuelend[PID]);
- }
- if(Maderequest[killerid] == 1)
- {
- new PID = Duelopponent[killerid];
- Maderequest[killerid] = 0;
- Gotrequest[PID] = 0;
- SetPlayerVirtualWorld(killerid,0);
- Duel[killerid] = 0;
- Duelrounds[killerid] = 0;
- SetPlayerVirtualWorld(PID,0);
- Duel[PID] = 0;
- Duelrounds[PID] = 0;
- SendClientMessage(killerid,COLOR_MAGENTA,"* The duel ended due to some issues.");
- SendClientMessage(PID,COLOR_MAGENTA,"* The duel ended due to some issues.");
- SpawnPlayer(killerid);
- SpawnPlayer(PID);
- KillTimer(UnDuelend[killerid]);
- KillTimer(UnDuelend[PID]);
- }
- }
- if(Duel[killerid] <2 && Duel[playerid] >=2)
- {
- if(Gotrequest[playerid] == 1)
- {
- new PID = Duelmaker[playerid];
- Gotrequest[playerid] = 0;
- Maderequest[PID] = 0;
- SetPlayerVirtualWorld(playerid,0);
- Duel[playerid] = 0;
- Duelrounds[playerid] = 0;
- SetPlayerVirtualWorld(PID,0);
- Duel[PID] = 0;
- Duelrounds[PID] = 0;
- SendClientMessage(playerid,COLOR_MAGENTA,"* The duel ended due to some issues.");
- SendClientMessage(PID,COLOR_MAGENTA,"* The duel ended due to some issues.");
- SpawnPlayer(playerid);
- SpawnPlayer(PID);
- KillTimer(UnDuelend[playerid]);
- KillTimer(UnDuelend[PID]);
- }
- if(Maderequest[playerid] == 1)
- {
- new PID = Duelopponent[playerid];
- Maderequest[playerid] = 0;
- Gotrequest[PID] = 0;
- SetPlayerVirtualWorld(playerid,0);
- Duel[playerid] = 0;
- Duelrounds[playerid] = 0;
- SetPlayerVirtualWorld(PID,0);
- Duel[PID] = 0;
- Duelrounds[PID] = 0;
- SendClientMessage(playerid,COLOR_MAGENTA,"* The duel ended due to some issues.");
- SendClientMessage(PID,COLOR_MAGENTA,"* The duel ended due to some issues.");
- SpawnPlayer(playerid);
- SpawnPlayer(PID);
- KillTimer(UnDuelend[playerid]);
- KillTimer(UnDuelend[PID]);
- }
- }
- return 1;
- }
- //------------------------------------------------------------------------------
- public DuelStart(playerid)
- {
- TogglePlayerControllable(playerid,1);
- GameTextForPlayer(playerid,"~b~GO GO GO",3000,4);
- PlayerPlaySound(playerid, 1057, 0.0, 0.0, 0.0);
- }
- public DuelTimer(playerid)
- {
- if(Duel[playerid] <2)
- {
- Duel[playerid] = 0;
- SendClientMessage(playerid,COLOR_AQUA,"* The duelrequest has not been answered within 30 seconds, so it's declined.");
- }
- return 1;
- }
- public DuelbetEnd(playerid)
- {
- DuelbetEnabled[playerid] = 0;
- return 1;
- }
- public UnnormalDuelend(playerid)
- {
- Maderequest[playerid] = 0;
- Gotrequest[playerid] = 0;
- SetPlayerVirtualWorld(playerid,0);
- Duel[playerid] = 0;
- Duelrounds[playerid] = 0;
- SendClientMessage(playerid,COLOR_MAGENTA,"* The duel ended because it took to long.");
- SpawnPlayer(playerid);
- return 1;
- }
- //------------------------------------------------------------------------------
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- if(dialogid == DIALOG_DUELWEAPONS)
- {
- if(response)
- {
- switch(listitem)
- {
- case 0: {
- PrepareDuelWeapon(playerid,24);}
- case 1: {
- PrepareDuelWeapon(playerid,25);}
- case 2: {
- PrepareDuelWeapon(playerid,26);}
- case 3: {
- PrepareDuelWeapon(playerid,27);}
- case 4: {
- PrepareDuelWeapon(playerid,28);}
- case 5: {
- PrepareDuelWeapon(playerid,29);}
- case 6: {
- PrepareDuelWeapon(playerid,30);}
- case 7: {
- PrepareDuelWeapon(playerid,31);}
- case 8: {
- PrepareDuelWeapon(playerid,32);}
- case 9: {
- PrepareDuelWeapon(playerid,33);}
- case 10: {
- PrepareDuelWeapon(playerid,34);}
- case 11: {
- PrepareDuelWeapon(playerid,0);}
- case 12: {
- PrepareDuelWeapon(playerid,4);}
- case 13: {
- PrepareDuelWeapon(playerid,8);}
- case 14: {
- PrepareDuelWeapon(playerid,9);}
- case 15: {
- PrepareDuelWeapon(playerid,22);}
- case 16: {
- PrepareDuelWeapon(playerid,23);}
- }
- }
- return 1;
- }
- if(dialogid == DIALOG_DUELWEAPONSTWO)
- {
- if(response)
- {
- switch(listitem)
- {
- case 0: {
- PrepareDuelWeapon2(playerid,24);}
- case 1: {
- PrepareDuelWeapon2(playerid,25);}
- case 2: {
- PrepareDuelWeapon2(playerid,26);}
- case 3: {
- PrepareDuelWeapon2(playerid,27);}
- case 4: {
- PrepareDuelWeapon2(playerid,28);}
- case 5: {
- PrepareDuelWeapon2(playerid,29);}
- case 6: {
- PrepareDuelWeapon2(playerid,30);}
- case 7: {
- PrepareDuelWeapon2(playerid,31);}
- case 8: {
- PrepareDuelWeapon2(playerid,32);}
- case 9: {
- PrepareDuelWeapon2(playerid,33);}
- case 10: {
- PrepareDuelWeapon2(playerid,34);}
- case 11: {
- PrepareDuelWeapon2(playerid,0);}
- case 12: {
- PrepareDuelWeapon2(playerid,4);}
- case 13: {
- PrepareDuelWeapon2(playerid,8);}
- case 14: {
- PrepareDuelWeapon2(playerid,9);}
- case 15: {
- PrepareDuelWeapon2(playerid,22);}
- case 16: {
- PrepareDuelWeapon2(playerid,23);}
- }
- }
- else
- {
- EndDuel(playerid);
- }
- return 1;
- }
- if(dialogid == DIALOG_DUELROUNDS)
- {
- if(response)
- {
- switch(listitem)
- {
- case 0: {
- PrepareDuelRounds(playerid,1);}
- case 1: {
- PrepareDuelRounds(playerid,2);}
- case 2: {
- PrepareDuelRounds(playerid,3);}
- case 3: {
- PrepareDuelRounds(playerid,4);}
- case 4: {
- PrepareDuelRounds(playerid,5);}
- case 5: {
- PrepareDuelRounds(playerid,6);}
- case 6: {
- PrepareDuelRounds(playerid,7);}
- }
- }
- else
- {
- EndDuel(playerid);
- }
- return 1;
- }
- return 0;
- }
- //------------------------------------------------------------------------------
- //This stocks just make the script a bit shorter.
- stock PrepareDuelWeapon(playerid,weaponid)
- {
- new PID = Duelopponent[playerid];
- if(Duel[PID] >=1) return SendClientMessage(playerid,COLOR_MAGENTA,"* This player is already in a duel.");
- {
- Duelweap1[playerid] = weaponid;
- Duelweap1[PID] = weaponid;
- Duel[PID] = 1;
- Duel[playerid] = 1;
- Duelwins[PID] = 0;
- Duelwins[playerid] = 0;
- ShowPlayerDialog(playerid, DIALOG_DUELWEAPONSTWO, DIALOG_STYLE_LIST, "{FF00FF}Second Duelweapon","{F0F8FF}Desert Eagle\n{F0F8FF}Shotgun\n{F0F8FF}Sawnoff Shotgun\n{F0F8FF}Combat Shotgun\n{F0F8FF}Micro SMG\n{F0F8FF}MP5\n{F0F8FF}AK-47\n{F0F8FF}M4\n{F0F8FF}Tec-9\n{F0F8FF}Country Rifle\n{F0F8FF}Sniper Rifle\n{F0F8FF}Fist\n{F0F8FF}Knife\n{F0F8FF}Katana\n{F0F8FF}Chainsaw\n{F0F8FF}Colt\n{F0F8FF}Silenced 9mm","Okey","Cancel");
- }
- return 1;
- }
- stock PrepareDuelWeapon2(playerid,weaponid)
- {
- new PID = Duelopponent[playerid];
- Duelweap2[playerid] = weaponid;
- Duelweap2[PID] = weaponid;
- SendClientMessage(playerid,COLOR_MAGENTA,"* You have chosen the duelweapons.");
- ShowPlayerDialog(playerid,DIALOG_DUELROUNDS,DIALOG_STYLE_LIST,"{FF00FF}How many rounds shall the duel last?","{F0F8FF}1 Round\n{F0F8FF}2 Rounds\n{F0F8FF}3 Rounds\n{F0F8FF}4 Rounds\n{F0F8FF}5 Rounds\n{F0F8FF}6 Rounds\n{F0F8FF}7 Rounds","Select","Cancel");
- return 1;
- }
- stock PrepareDuelRounds(playerid,rounds)
- {
- new PID = Duelopponent[playerid];
- new string[160],Weaponname[32],Weaponname2[32];
- Duelrounds[playerid] = rounds;
- Duelrounds[PID] = rounds;
- GetWeaponName(Duelweap1[playerid],Weaponname,32);
- GetWeaponName(Duelweap2[playerid],Weaponname2,32);
- format(string,sizeof(string),"--> DUELINVITATION from %s [id:%i]. Weapons: {F0F8FF}%s, %s {FF00FF}Rounds: {F0F8FF}%i",PlayerName(playerid),playerid,Weaponname,Weaponname2,rounds);
- SendClientMessage(PID,-1," ");
- SendClientMessage(PID,COLOR_MAGENTA,string);
- SendClientMessage(PID,COLOR_AQUA,"* You're invited to have a duel.");
- SendClientMessage(PID,COLOR_AQUA,"* Use /accept or /cancel to answer the duelrequest.");
- SendClientMessage(playerid,COLOR_MAGENTA,"* Your duelrequest has been send successfully.");
- DuelEndTimer[playerid] = SetTimerEx("DuelTimer",30000,false,"i",playerid);//Here you can change the time after which the duel will be automatically denied.
- DuelEndTimer[PID] = SetTimerEx("DuelTimer",30000,false,"i",PID);//Same, just for the other duelopponent.
- return 1;
- }
- stock EndDuel(playerid)
- {
- new PID = Duelopponent[playerid];
- Duel[playerid] = 0;
- Duel[PID] = 0;
- return 1;
- }
- stock PlayerName(playerid)
- {
- new name[MAX_PLAYER_NAME];
- GetPlayerName(playerid,name,sizeof(name));
- return name;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement