Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*==============================================================================
- ** SA-MP (0.3.7) DUel Filterscript v1.0
- ** By: DragonZafiro/NeloAngelo
- ** Created: 18/03/16
- ==============================================================================*/
- #include <a_samp>
- #include <zcmd>
- #include <sscanf2>
- #include <YSI\y_colours>
- #include "../include/gl_common.inc"
- #define FILTERSCRIPT
- #define COLOR_ADVICE X11_RED
- #define COLOR_SUCCESS X11_LIMEGREEN
- #define PLAIN_TEXT "{FFFAFA}"
- #define M_TEXT "{808080}"
- #define M_TITLE "{45FF00}"
- new tempTeam[MAX_PLAYERS]; // TEAM TEMPORAL
- enum pInfo
- {
- ActiveDuel,
- onDuel,
- DuelInvited,
- DuelReceived,
- DuelWatching
- };
- new PlayerInfo[MAX_PLAYERS][pInfo];
- new DuelDoors[2];
- new DuelTimer;
- new Text:DuelSpec;
- #define DIALOG_DUEL_WEAPONS 51
- #define DIALOG_DUEL_INVITE 52
- #define DIALOG_DUEL_SPEC 53
- public OnFilterScriptInit()
- {
- CreateObject(985, 2658.97021, 1223.53833, 27.63396, 0.00000, 0.00000, 270.00000);
- CreateObject(985, 2658.98682, 1215.67554, 27.63396, 0.00000, 0.00000, 270.00000);
- CreateObject(985, 2658.98584, 1207.79749, 27.63396, 0.00000, 0.00000, 270.00000);
- CreateObject(985, 2658.97974, 1199.92932, 27.63396, 0.00000, 0.00000, 270.00000);
- CreateObject(986, 2658.98218, 1191.97839, 27.63396, 0.00000, 0.00000, 90.00000);
- CreateObject(986, 2658.97705, 1231.47131, 27.63396, 0.00000, 0.00000, 90.00000);
- CreateObject(983, 2658.94946, 1187.32385, 29.15171, 269.75909, 0.00000, 0.00000);
- CreateObject(1468, 2659.02881, 1186.75110, 27.18706, 0.00000, 269.75909, 90.85940);
- CreateObject(1468, 2659.01880, 1186.74170, 30.46206, 0.00000, 269.75909, 90.85940);
- CreateObject(986, 2631.37769, 1231.48218, 27.62882, 0.00000, 0.00000, 90.00000);
- CreateObject(986, 2631.38843, 1223.46484, 27.63396, 0.00000, 0.00000, 90.00000);
- CreateObject(986, 2631.39453, 1215.44385, 27.63396, 0.00000, 0.00000, 90.00000);
- CreateObject(986, 2631.39014, 1207.42273, 27.63396, 0.00000, 0.00000, 90.00000);
- CreateObject(986, 2631.38135, 1199.40869, 27.63396, 0.00000, 0.00000, 90.00000);
- CreateObject(986, 2631.37769, 1191.38794, 27.63396, 0.00000, 0.00000, 90.00000);
- CreateObject(1468, 2631.36646, 1186.16077, 28.56204, 0.00000, 90.24080, 270.48181);
- CreateObject(1468, 2631.36646, 1186.15320, 30.46203, 0.00000, 90.24080, 270.48181);
- CreateObject(987, 2631.45972, 1235.70264, 26.94314, 0.00000, 0.00000, 0.00000);
- CreateObject(987, 2643.42334, 1235.68005, 26.91814, 0.00000, 0.00000, 0.00000);
- CreateObject(987, 2647.08740, 1235.69678, 26.94315, 0.00000, 0.00000, 0.00000);
- CreateObject(987, 2643.23853, 1186.14905, 26.91815, 0.00000, 0.00000, 180.00000);
- CreateObject(987, 2655.19287, 1186.14929, 26.94314, 0.00000, 0.00000, 180.00000);
- CreateObject(987, 2658.89355, 1186.13464, 26.94206, 0.00000, 0.00000, 180.00000);
- CreateObject(988, 2648.85791, 1232.85437, 26.95722, 0.00000, 0.00000, 90.00000);
- CreateObject(988, 2643.47607, 1232.70288, 26.95722, 0.00000, 0.00000, 270.00000);
- CreateObject(988, 2646.05737, 1234.20801, 31.01233, 270.61859, 0.00000, 180.00000);
- CreateObject(988, 2643.48584, 1189.04944, 26.95722, 0.00000, 0.00000, 270.00000);
- CreateObject(988, 2648.90845, 1189.16089, 26.95722, 0.00000, 0.00000, 90.00020);
- CreateObject(988, 2646.25464, 1187.70081, 31.01859, 270.61859, 0.00000, 0.00010);
- CreateObject(3819, 2663.85181, 1223.96643, 26.92105, 0.00000, 0.00000, 0.00000);
- CreateObject(3819, 2663.85693, 1215.37488, 26.92105, 0.00000, 0.00000, 0.00000);
- CreateObject(3819, 2663.85327, 1206.77734, 26.92105, 0.00000, 0.00000, 0.00000);
- CreateObject(3819, 2663.85059, 1198.16992, 26.92105, 0.00000, 0.00000, 0.00000);
- CreateObject(3819, 2626.50415, 1197.89392, 26.92105, 0.00000, 0.00000, 180.00000);
- CreateObject(3819, 2626.50391, 1206.49182, 26.92105, 0.00000, 0.00000, 180.00000);
- CreateObject(3819, 2626.49585, 1215.07849, 26.92105, 0.00000, 0.00000, 180.00000);
- CreateObject(3819, 2626.49756, 1223.67383, 26.92105, 0.00000, 0.00000, 180.00000);
- CreateObject(3528, 2645.73853, 1233.81335, 34.38435, 0.00000, 0.00000, 270.00000);
- CreateObject(3528, 2646.61523, 1188.38440, 34.48753, 0.00000, 0.00000, 90.00000);
- CreateObject(983, 2631.42212, 1186.72498, 29.15200, -89.38100, 0.00000, 0.85900);
- CreateObject(976, 2666.74194, 1220.18396, 27.22200, 0.00000, 0.00000, 90.24100);
- CreateObject(976, 2666.77197, 1211.32800, 27.23000, 0.00000, 0.00000, 90.24100);
- CreateObject(976, 2666.77002, 1202.50696, 27.22800, 0.00000, 0.00000, 90.24100);
- CreateObject(976, 2666.77490, 1193.65100, 27.21600, 0.00000, 0.00000, 90.24100);
- CreateObject(976, 2623.68091, 1220.20300, 27.22200, 0.00000, 0.00000, 90.24100);
- CreateObject(976, 2623.72095, 1211.39099, 27.22200, 0.00000, 0.00000, 90.24100);
- CreateObject(976, 2623.75610, 1202.56299, 27.21100, 0.00000, 0.00000, 90.24100);
- CreateObject(976, 2623.71802, 1193.72095, 27.17200, 0.00000, 0.00000, 90.24100);
- DuelDoors[0] = CreateObject(988, 2646.2058, 1230.0742, 26.9624, 0.0000, 0.0000, 0.0000);
- DuelDoors[1] = CreateObject(988, 2646.165771, 1191.811157, 26.957216, 0.0000, 0.0000, 180.0001);
- DuelSpec = TextDrawCreate(160.000000, 361.000000, "~b~] ~w~Press ~r~ ~k~~PED_SPRINT~ ~w~to stop watching ~b~]");
- TextDrawFont(DuelSpec, 2);
- TextDrawLetterSize(DuelSpec, 0.360000, 1.600000);
- TextDrawColor(DuelSpec, -1);
- TextDrawSetOutline(DuelSpec, 1);
- TextDrawSetProportional(DuelSpec, 1);
- for(new i = 0, j = GetPlayerPoolSize(); i <= j; i++)
- {
- if(IsPlayerConnected(i))
- {
- PlayerInfo[i][onDuel] = 0;
- PlayerInfo[i][ActiveDuel] = 1;
- PlayerInfo[i][DuelInvited] = -1;
- PlayerInfo[i][DuelReceived] = -1;
- }
- }
- return 1;
- }
- public OnFilterScriptExit()
- {
- DestroyObject(DuelDoors[0]);
- DestroyObject(DuelDoors[1]);
- return 1;
- }
- forward CancelDuel(playerid, invited);
- public CancelDuel(playerid, invited)
- {
- PlayerInfo[playerid][DuelInvited] = -1;
- PlayerInfo[playerid][DuelReceived] = -1;
- PlayerInfo[invited][DuelInvited] = -1;
- PlayerInfo[invited][DuelReceived] = -1;
- SendClientMessage(playerid, COLOR_ADVICE, "[!]: "PLAIN_TEXT"Duel time has expired.");
- SendClientMessage(invited, COLOR_ADVICE, "[!]: "PLAIN_TEXT"Duel time has expired.");
- return 1;
- }
- forward StartDuel(movedoor);
- public StartDuel(movedoor)
- {
- if(movedoor == 1)
- {
- MoveObject(DuelDoors[0], 2646.2058, 1230.0742, 32.0, 3.0, 0.0, 0.0, 0.0);
- MoveObject(DuelDoors[1], 2646.165771, 1191.811157, 32.0, 3.0, 0.0, 0.0, 180.0001);
- }
- else
- {
- MoveObject(DuelDoors[0], 2646.2058, 1230.0742, 26.9624, 3.0, 0.0, 0.0, 0.0);
- MoveObject(DuelDoors[1], 2646.165771, 1191.811157, 26.9624, 3.0, 0.0, 0.0, 180.0001);
- }
- return 1;
- }
- SetupDuel(playerid, oponent, weapons)
- {
- if(PlayerInfo[playerid][DuelWatching] == 1)
- {
- TogglePlayerSpectating(playerid, 0);
- PlayerInfo[playerid][DuelWatching] = 0;
- }
- if(PlayerInfo[oponent][DuelWatching] == 1)
- {
- TogglePlayerSpectating(oponent, 0);
- PlayerInfo[oponent][DuelWatching] = 0;
- }
- KillTimer(DuelTimer);
- new str[200], weapon[20];
- GetPVarString(oponent, "DuelWeapons", weapon, sizeof(weapon));
- format(str, sizeof(str), "[Duel]: "PLAIN_TEXT"A duel between "M_TITLE"%s v "M_TITLE"%s "PLAIN_TEXT"[%s] Will start in 10 seconds...",
- PlayerName(playerid), PlayerName(oponent), weapon);
- SendClientMessageToAll(COLOR_ADVICE, str);
- ResetPlayerWeapons(playerid);
- ResetPlayerWeapons(oponent);
- if(weapons == 0) // RW SET
- {
- GivePlayerWeapon(playerid, WEAPON_UZI, 1000);
- GivePlayerWeapon(playerid, WEAPON_COLT45, 1000);
- GivePlayerWeapon(playerid, WEAPON_SAWEDOFF, 1000);
- GivePlayerWeapon(oponent, WEAPON_UZI, 1000);
- GivePlayerWeapon(oponent, WEAPON_COLT45, 1000);
- GivePlayerWeapon(oponent, WEAPON_SAWEDOFF, 1000);
- }
- else if(weapons == 1) // WW SET
- {
- GivePlayerWeapon(playerid, WEAPON_DEAGLE, 1000);
- GivePlayerWeapon(playerid, WEAPON_SHOTGUN, 1000);
- GivePlayerWeapon(playerid, WEAPON_SNIPER, 1000);
- GivePlayerWeapon(oponent, WEAPON_DEAGLE, 1000);
- GivePlayerWeapon(oponent, WEAPON_SHOTGUN, 1000);
- GivePlayerWeapon(oponent, WEAPON_SNIPER, 1000);
- }
- SetPlayerPos(playerid, 2646.134033, 1232.647460, 26.918153);
- SetPlayerFacingAngle(playerid, 183.424057);
- SetPlayerInterior(playerid, 0);
- SetPlayerVirtualWorld(playerid, playerid + 1);
- tempTeam[playerid] = GetPlayerTeam(playerid);
- SetPlayerTeam(playerid, playerid); // Remover TEAM
- SetPlayerPos(oponent, 2645.674804, 1190.122802, 26.918153);
- SetPlayerFacingAngle(oponent, 359.496429);
- SetPlayerInterior(oponent, 0);
- SetPlayerVirtualWorld(oponent, playerid + 1);
- tempTeam[oponent] = GetPlayerTeam(oponent);
- SetPlayerTeam(oponent, oponent); // Remover TEAM
- PlayerInfo[playerid][onDuel] = 1;
- PlayerInfo[oponent][onDuel] = 1;
- SetTimerEx("StartDuel", 10000, false, "d", 1);
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- if(PlayerInfo[playerid][onDuel] != 0)
- {
- new str[124];
- format(str, sizeof(str), "[Duel]: "PLAIN_TEXT"%s has been left the server...", PlayerName(playerid));
- SendClientMessageToAll(COLOR_ADVICE, str);
- StartDuel(0);
- for(new i = 0, j = GetPlayerPoolSize(); i <= j; i++)
- {
- if(IsPlayerConnected(i) && PlayerInfo[i][onDuel] == 1)
- {
- SetPlayerTeam(i, tempTeam[i]);
- SpawnPlayer(i);
- PlayerInfo[i][onDuel] = 0;
- PlayerInfo[i][DuelInvited] = -1;
- PlayerInfo[i][DuelReceived] = -1;
- }
- }
- }
- return 1;
- }
- public OnPlayerDeath(playerid,killerid,reason)
- {
- if(PlayerInfo[playerid][onDuel] != 0 && PlayerInfo[killerid][onDuel] != 0)
- {
- new str[254];
- format(str, sizeof(str), "[Duel]: "PLAIN_TEXT"%s has won the duel against %s...", PlayerName(killerid), PlayerName(playerid));
- SendClientMessageToAll(COLOR_ADVICE, str);
- SetPlayerTeam(killerid, tempTeam[killerid]);
- SetPlayerTeam(playerid, tempTeam[playerid]);
- SpawnPlayer(killerid);
- PlayerInfo[playerid][onDuel] = 0;
- PlayerInfo[killerid][onDuel] = 0;
- PlayerInfo[playerid][DuelInvited] = -1;
- PlayerInfo[playerid][DuelReceived] = -1;
- PlayerInfo[killerid][DuelInvited] = -1;
- PlayerInfo[killerid][DuelReceived] = -1;
- StartDuel(0);
- }
- if(killerid == INVALID_PLAYER_ID)
- {
- for(new i = 0, j = GetPlayerPoolSize(); i <= j; i++)
- {
- if(IsPlayerConnected(i) && PlayerInfo[i][onDuel] == 1)
- {
- SetPlayerTeam(i, tempTeam[i]);
- SpawnPlayer(i);
- PlayerInfo[i][onDuel] = 0;
- PlayerInfo[i][DuelInvited] = -1;
- PlayerInfo[i][DuelReceived] = -1;
- }
- }
- }
- return 1;
- }
- CMD:duelo(playerid, params[])
- {
- new Float:health;
- GetPlayerHealth(playerid, health);
- if(health < 50.0) return SendClientMessage(playerid, COLOR_ADVICE, "[!]: "PLAIN_TEXT"You cannot use this command with low HP.");
- if(isnull(params)) return SendClientMessage(playerid, COLOR_ADVICE, "[!]: "PLAIN_TEXT"Use: /Duel [Invite | View | Accept | Decline | Enable | Disable]");
- if(strfind(params, "invite", true) != -1)
- {
- if(PlayerInfo[playerid][ActiveDuel] != 1) return SendClientMessage(playerid, COLOR_ADVICE, "[!]: "PLAIN_TEXT"You have disabled the duels. Use: /Duel Enable");
- if(PlayerInfo[playerid][DuelInvited] != -1) return SendClientMessage(playerid, COLOR_ADVICE, "[!]: "PLAIN_TEXT"You've already invited a player to a duel.");
- if(PlayerInfo[playerid][DuelReceived] != -1) return SendClientMessage(playerid, COLOR_ADVICE, "[!]: "PLAIN_TEXT"You're invited to a duel. Use: /Duel Decline");
- ShowPlayerDialog(playerid, DIALOG_DUEL_WEAPONS, DIALOG_STYLE_LIST, ""M_TITLE"Select the weapons:", "{FAFAFA}Running Weapons(RW)\nWalking Weapons(WW)", "Select", "Cancel");
- return 1;
- }
- if(strfind(params, "view", true) != -1)
- {
- if(PlayerInfo[playerid][DuelWatching] != 0) return SendClientMessage(playerid, COLOR_ADVICE, "[!]: "PLAIN_TEXT"You're watching a duel.");
- new PlayerList[120];
- for(new i = 0, j = GetPlayerPoolSize(); i <= j; i++)
- {
- if(IsPlayerConnected(i) && PlayerInfo[i][onDuel] != 0 && playerid != i)
- {
- strcat(PlayerList, PlayerName(i));
- strcat(PlayerList, "\n");
- }
- }
- if(!isnull(PlayerList)) ShowPlayerDialog(playerid, DIALOG_DUEL_SPEC, DIALOG_STYLE_LIST, ""M_TITLE"Select a player:", PlayerList, "Select", "Cancel");
- else SendClientMessage(playerid, COLOR_ADVICE, "[!]: "PLAIN_TEXT"There's noone on a duel.");
- return 1;
- }
- if(strfind(params, "accept", true) != -1)
- {
- if(PlayerInfo[playerid][DuelReceived] != -1)
- SetupDuel(playerid, PlayerInfo[playerid][DuelReceived], GetPVarInt(PlayerInfo[playerid][DuelReceived], "DuelWeaponsID"));
- else SendClientMessage(playerid, COLOR_ADVICE, "[!]: "PLAIN_TEXT"You aren't invited to a duel.");
- return 1;
- }
- if(strfind(params, "decline", true) != -1)
- {
- if(PlayerInfo[playerid][DuelReceived] != -1)
- {
- new str[254];
- SendClientMessage(playerid, COLOR_SUCCESS, "You have declined the duel, you can now receive invitations to a duel.");
- format(str, sizeof(str), "%s "PLAIN_TEXT"Has declined your invitation to a duel.", PlayerName(playerid));
- SendClientMessage(PlayerInfo[playerid][DuelReceived], GetPlayerColor(playerid), str);
- PlayerInfo[PlayerInfo[playerid][DuelReceived]][DuelInvited] = -1;
- PlayerInfo[playerid][DuelReceived] = -1;
- KillTimer(DuelTimer);
- }
- else SendClientMessage(playerid, COLOR_ADVICE, "[!]: "PLAIN_TEXT"You have not invitations to a duel.");
- return 1;
- }
- if(strfind(params, "enable", true) != -1)
- {
- PlayerInfo[playerid][ActiveDuel] = 1;
- SendClientMessage(playerid, COLOR_SUCCESS, "You have enabled the invitations to a duel.");
- return 1;
- }
- if(strfind(params, "disable", true) != -1)
- {
- PlayerInfo[playerid][ActiveDuel] = 0;
- SendClientMessage(playerid, COLOR_SUCCESS, "You have disabled the invitations to a duel.");
- return 1;
- }
- else SendClientMessage(playerid, COLOR_ADVICE, "[!]: "PLAIN_TEXT"Use: /Duel [Invite | View | Accept | Decline | Enable | Disable]");
- return 1;
- }
- public OnPlayerCommandReceived(playerid, cmdtext[])
- {
- // ON DUEL
- if( PlayerInfo[playerid][onDuel] == 1 )
- {
- SendClientMessage(playerid, COLOR_ADVICE, "[!]: "PLAIN_TEXT"You can't use commands on a duel!");
- return 0;
- }
- return 1;
- }
- public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
- {
- if(newkeys == KEY_SPRINT)
- {
- if(PlayerInfo[playerid][DuelWatching] == 1)
- {
- TogglePlayerSpectating(playerid, 0);
- TextDrawHideForPlayer(playerid, DuelSpec);
- }
- }
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- switch(dialogid)
- {
- case DIALOG_DUEL_SPEC:
- {
- if(response)
- {
- new id;
- if(sscanf(inputtext, "u", id)) SendClientMessage(playerid, COLOR_ADVICE, "[!]: "PLAIN_TEXT"Player disconnected.");
- else
- {
- PlayerInfo[playerid][DuelWatching] = 1;
- TogglePlayerSpectating(playerid, 1);
- SetPlayerVirtualWorld(playerid, GetPlayerVirtualWorld(id));
- SetPlayerInterior(playerid, GetPlayerInterior(id));
- PlayerSpectatePlayer(playerid, id);
- TextDrawShowForPlayer(playerid, DuelSpec);
- }
- }
- }
- case DIALOG_DUEL_WEAPONS:
- {
- if(response)
- {
- new PlayerList[120];
- SetPVarString(playerid, "DuelWeapons", inputtext);
- SetPVarInt(playerid, "DuelWeaponsID", listitem);
- for(new i = 0, j = GetPlayerPoolSize(); i <= j; i++)
- {
- if(IsPlayerConnected(i) && PlayerInfo[i][ActiveDuel] != 0&& playerid != i)
- {
- strcat(PlayerList, PlayerName(i));
- strcat(PlayerList, "\n");
- }
- }
- if(!isnull(PlayerList)) ShowPlayerDialog(playerid, DIALOG_DUEL_INVITE, DIALOG_STYLE_LIST, ""M_TITLE"Select the player:", PlayerList, "Select", "Cancel");
- else SendClientMessage(playerid, COLOR_ADVICE, "[!]: "PLAIN_TEXT"There's no one online.");
- }
- }
- case DIALOG_DUEL_INVITE:
- {
- if(response)
- {
- new invited;
- if(sscanf(inputtext, "u", invited)) SendClientMessage(playerid, COLOR_ADVICE, "[!]: "PLAIN_TEXT"Player disconnected.");
- else if(PlayerInfo[invited][onDuel] != 0) SendClientMessage(playerid, COLOR_ADVICE, "[!]: "PLAIN_TEXT"This player is already on a duel. Use: /Duel View");
- else if(PlayerInfo[invited][DuelReceived] != -1 || PlayerInfo[invited][DuelInvited] != -1)
- SendClientMessage(playerid, COLOR_ADVICE, "[!]: "PLAIN_TEXT"This player has already a invitation, wait for his response.");
- else
- {
- new str[200], weapon[30];
- PlayerInfo[playerid][DuelInvited] = invited;
- PlayerInfo[invited][DuelReceived] = playerid;
- GetPVarString(playerid, "DuelWeapons", weapon, sizeof(weapon));
- format(str, sizeof(str), "You've invited %s to a duel (%s), wait for his response.", PlayerName(invited), weapon);
- SendClientMessage(playerid, COLOR_SUCCESS, str);
- format(str, sizeof(str), "! %s "PLAIN_TEXT"Has invited you to a duel (%s), Use (/Duel Accept) or (/Duel Decline)", PlayerName(playerid), weapon);
- SendClientMessage(invited, GetPlayerColor(playerid), str);
- DuelTimer = SetTimerEx("CancelDuel", 30000, 0, "dd", playerid, invited);
- }
- }
- }
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement