Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <sscanf2>
- #include <zcmd>
- #define START_TIME 30000 // Time in milliseconds
- #define END_TIME 30000 // Time in milliseconds
- #define COUNT_DOWN_SECONDS 6
- #define C1 "{DBED15}"
- #define C2 "{BABABA}"
- #define RED "{FF0000}"
- #define LMS_CHOOSE_WEAPON 9876
- #define function%0(%1) \
- forward%0(%1); public%0(%1)
- new startTimer;
- new initiateTimer;
- new cdTimer;
- new IsLMSactive;
- new IsLMSstarted;
- new lmsCount;
- new countVal;
- new PlayerText:rInfoTDS[MAX_PLAYERS];
- new playerJoined[MAX_PLAYERS];
- forward startLMS();
- forward initiateLMS();
- forward lmsCountDown();
- public OnFilterScriptInit()
- {
- print("\n--------------------------------------");
- print(" Last Man Standing | Author: SyntaxQ");
- print("--------------------------------------\n");
- IsLMSactive = 0;
- IsLMSstarted = 0;
- lmsCount = 0;
- startTimer = SetTimer("startLMS", START_TIME, false);
- return 1;
- }
- public OnFilterScriptExit()
- {
- return 1;
- }
- public startLMS()
- {
- if (IsLMSactive == 1)
- {
- return 0;
- }
- SendClientMessageToAll(-1, ""C1"[LMS] "C2"A last man standing event has started! Type "RED"/lms "C2"to join");
- for (new i = 0; i < MAX_PLAYERS; i++)
- {
- if (IsPlayerConnected(i))
- {
- TD_MSG(i, 3000, "~w~A last man standing has started! Type ~h~~r~/lms ~w~to join!");
- }
- }
- IsLMSactive = 1;
- initiateTimer = SetTimer("initiateLMS", END_TIME, false);
- return 1;
- }
- public initiateLMS()
- {
- new str[128];
- KillTimer(startTimer);
- if (lmsCount == 0)
- {
- SendClientMessageToAll(-1, ""C1"[LMS] "C2"Last Man Standing has cancelled due to lack of players! [Atleast "RED"2 "C2"players needed]");
- IsLMSactive = 0;
- IsLMSstarted = 0;
- KillTimer(initiateTimer);
- startTimer = SetTimer("startLMS", START_TIME, false);
- return 1;
- }
- format(str, sizeof(str), ""C1"[LMS] "C2"Last Man Standing has started! [Total Players: "RED"%d"C2"]", lmsCount);
- IsLMSstarted = 1;
- SendClientMessageToAll(-1, str);
- for (new i = 0; i < MAX_PLAYERS; i++)
- {
- if (IsPlayerConnected(i))
- {
- if (playerJoined[i] == 1)
- {
- SendClientMessage(i, -1, ""C1"[LMS] "RED"The countdown begins...Get ready!");
- }
- }
- }
- cdTimer = SetTimer("lmsCountDown", 1000, false);
- countVal = COUNT_DOWN_SECONDS;
- return 1;
- }
- public lmsCountDown()
- {
- countVal--;
- KillTimer(initiateTimer);
- if (countVal == 0)
- {
- for (new i = 0; i < MAX_PLAYERS; i++)
- {
- if (IsPlayerConnected(i))
- {
- if (playerJoined[i] == 1)
- {
- GameTextForPlayer(i, "~r~~r~FIGHT!", 1000, 4);
- TogglePlayerControllable(i, true);
- KillTimer(cdTimer);
- }
- }
- }
- }
- else
- {
- new c_val_str[10];
- format(c_val_str, sizeof(c_val_str), "~b~~w~%d", countVal);
- for (new i = 0; i < MAX_PLAYERS; i++)
- {
- if (IsPlayerConnected(i))
- {
- if (playerJoined[i] == 1)
- {
- GameTextForPlayer(i, c_val_str, 1000, 4);
- cdTimer = SetTimer("lmsCountDown", 1000, false);
- }
- }
- }
- }
- return 1;
- }
- CMD:lms (playerid)
- {
- new str[128];
- if (IsLMSactive == 0) return SendClientMessage(playerid, -1, ""RED"ERROR: "C2"Last Man Standing is not active.");
- if (playerJoined[playerid] == 1) return SendClientMessage(playerid, -1, ""RED"ERROR: "C2"You have already joined!");
- if (IsLMSstarted == 1) return SendClientMessage(playerid, -1, ""RED"ERROR: "C2"Last Man Standing has already started!");
- lmsCount++;
- format(str, sizeof(str), ""C1"[LMS] "C2"%s(%d) has joined the Last Man Standing event! [Total Players: "RED"%d"C2"]", GetName(playerid), playerid, lmsCount);
- SendClientMessageToAll(-1, str);
- new Float:RandomSpawns[][] =
- {
- {7.6998,36.5756,4199.5747,179.6044},
- {7.9292,-10.2401,4199.5947,359.7493}
- };
- new Random = random(sizeof(RandomSpawns));
- SetPlayerPosEx(playerid, RandomSpawns[Random][0], RandomSpawns[Random][1], RandomSpawns[Random][2], RandomSpawns[Random][3], 0, 1);
- TogglePlayerControllable(playerid, false);
- TD_MSG(playerid, 3000, "~w~You have joined ~h~~r~Last Man Standing~w~!");
- SetCameraBehindPlayer(playerid);
- ShowPlayerDialog(playerid, LMS_CHOOSE_WEAPON, DIALOG_STYLE_LIST, ""RED"Choose a weapon for fight:", "• Deagle - M4 - Uzi - 9mm\n• Sawn-off Shotgun - MP5 - Tec9 - s9mm\n• Combat Shotgun - AK47 - Shotgun - 9mm", "Select", "");
- playerJoined[playerid] = 1;
- return 1;
- }
- CMD:exitlms (playerid)
- {
- new str[128];
- if (IsLMSactive == 0) return SendClientMessage(playerid, -1, ""RED"ERROR: "C2"Last Man Standing is not active.");
- if (playerJoined[playerid] == 0) return SendClientMessage(playerid, -1, ""RED"ERROR: "C2"You have not joined LMS!");
- lmsCount--;
- format(str, sizeof(str), ""C1"[LMS] "C2"%s(%d) has left the Last Man Standing event [Total Players: "RED"%d"C2"]", GetName(playerid), playerid, lmsCount);
- SendClientMessageToAll(-1, str);
- TD_MSG(playerid, 2000, "~w~You have left ~h~~r~Last Man Standing~w~!");
- playerJoined[playerid] = 0;
- SetPlayerPosEx(playerid, 2188.6184, 1681.6017, 11.1150, 90.3735, 0, 0);
- SetCameraBehindPlayer(playerid);
- TogglePlayerControllable(playerid, true);
- ResetPlayerWeapons(playerid);
- return 1;
- }
- CMD:startlms (playerid)
- {
- new str[128];
- if (!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, ""RED"ERROR: "C2"You must be RCON admin to use this command!");
- if (IsLMSactive == 1) return SendClientMessage(playerid, -1, ""RED"ERROR: "C2"A lms event is already active.");
- format(str, sizeof(str), ""C1"[ADMIN] "RED"RCON administrator %s(%d) has manually started Last Man Standing event.", GetName(playerid), playerid);
- startLMS();
- SendClientMessageToAll(-1, str);
- return 1;
- }
- CMD:stoplms (playerid)
- {
- new str[128];
- if (!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, ""RED"ERROR: "C2"You must be RCON admin to use this command!");
- if (IsLMSactive == 0) return SendClientMessage(playerid, -1, ""RED"ERROR: "C2"No lms events are active.");
- for (new i = 0; i < MAX_PLAYERS; i++)
- {
- if (IsPlayerConnected(i))
- {
- if (playerJoined[i] == 1)
- {
- SendClientMessage(i, -1, ""C1"[LMS] "RED"Last Man Standing cancelled by an Administrator.");
- TD_MSG(i, 2000, "~r~Last Man Standing ~w~cancelled!");
- SetPlayerPosEx(i, 2188.6184, 1681.6017, 11.1150, 90.3735, 0, 0);
- SetCameraBehindPlayer(i);
- TogglePlayerControllable(i, true);
- ResetPlayerWeapons(i);
- playerJoined[i] = 0;
- }
- }
- }
- format(str, sizeof(str), ""C1"[ADMIN] "RED"RCON Administrator %s(%d) has cancelled the current Last Man Standing event.", GetName(playerid), playerid);
- SendClientMessageToAll(-1, str);
- KillTimer(startTimer);
- KillTimer(initiateTimer);
- KillTimer(cdTimer);
- IsLMSactive = 0;
- IsLMSstarted = 0;
- lmsCount = 0;
- startTimer = SetTimer("startLMS", START_TIME, false);
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- LoadPlayerTextDraws(playerid);
- playerJoined[playerid] = 0;
- return 1;
- }
- public OnPlayerDeath(playerid, killerid, reason)
- {
- new str[128];
- if (playerJoined[playerid] == 1 && IsLMSactive == 1)
- {
- if(killerid != INVALID_PLAYER_ID)
- {
- lmsCount--;
- if (lmsCount == 1)
- {
- for (new i = 0; i < MAX_PLAYERS; i++)
- {
- if (IsPlayerConnected(i))
- {
- if (playerJoined[i] == 1)
- {
- format(str, sizeof(str), ""C1"[LMS] "C2"%s(%d) "RED"has won the Last Man Standing event! "C2"(+5 score & $50000)", GetName(i), i);
- SetPlayerScore(i, GetPlayerScore(i) + 5);
- GivePlayerMoney(i, 50000);
- IsLMSactive = 0;
- IsLMSstarted = 0;
- playerJoined[i] = 0;
- SendClientMessageToAll(-1, str);
- lmsCount = 0;
- TD_MSG(i, 3000, "~w~You have ~g~won ~w~the last man standing!");
- startTimer = SetTimer("startLMS", START_TIME, false);
- return 1;
- }
- }
- }
- }
- format(str, sizeof(str), ""C1"[LMS] "C2"%s(%d) has been eliminated by %s(%d)! [Total Players: "RED"%d"C2"]", GetName(playerid), playerid, GetName(killerid), killerid, lmsCount);
- SendClientMessageToAll(-1, str);
- SetPlayerScore(killerid, GetPlayerScore(killerid) + 1);
- GivePlayerMoney(killerid, 1000);
- SetPlayerPosEx(playerid, 2188.6184, 1681.6017, 11.1150, 90.3735, 0, 0);
- TD_MSG(killerid, 3000, "~w~~g~+1 score & $1000!");
- playerJoined[playerid] = 0;
- }
- }
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- if (dialogid == LMS_CHOOSE_WEAPON)
- {
- if (response)
- {
- switch (listitem)
- {
- case 0:
- {
- GivePlayerWeapon(playerid, 24, 20);
- GivePlayerWeapon(playerid, 31, 20);
- GivePlayerWeapon(playerid, 28, 60);
- GivePlayerWeapon(playerid, 22, 100);
- TD_MSG(playerid, 2000, "~r~Weapons updated!");
- }
- case 1:
- {
- GivePlayerWeapon(playerid, 26, 20);
- GivePlayerWeapon(playerid, 29, 20);
- GivePlayerWeapon(playerid, 32, 60);
- GivePlayerWeapon(playerid, 22, 100);
- TD_MSG(playerid, 2000, "~r~Weapons updated!");
- }
- case 2:
- {
- GivePlayerWeapon(playerid, 27, 20);
- GivePlayerWeapon(playerid, 30, 20);
- GivePlayerWeapon(playerid, 32, 60);
- GivePlayerWeapon(playerid, 22, 100);
- TD_MSG(playerid, 2000, "~r~Weapons updated!");
- }
- }
- }
- }
- return 0;
- }
- //-----------------------
- // Additional Functions
- //-----------------------
- // Note: Some functions are not created by me (SyntaxQ).
- stock LoadPlayerTextDraws(playerid)
- {
- rInfoTDS[ playerid ] = CreatePlayerTextDraw( playerid, 165.000000, 371.000000, " " );
- PlayerTextDrawAlignment( playerid, rInfoTDS[ playerid ], 1 );
- PlayerTextDrawBackgroundColor( playerid, rInfoTDS[ playerid ], 0x000000ff );
- PlayerTextDrawFont( playerid, rInfoTDS[ playerid ], 1 );
- PlayerTextDrawLetterSize( playerid, rInfoTDS[ playerid ], 0.299999, 1.200000 );
- PlayerTextDrawColor( playerid, rInfoTDS[ playerid ], 0xffffffff );
- PlayerTextDrawSetOutline( playerid, rInfoTDS[ playerid ], 1 );
- PlayerTextDrawSetProportional( playerid, rInfoTDS[ playerid ], 1 );
- PlayerTextDrawSetShadow( playerid, rInfoTDS[ playerid ], 1 );
- PlayerTextDrawSetSelectable( playerid, rInfoTDS[ 2 ], 0 );
- return 1;
- }
- function TD_MSG_FOR_ALL( playerid, ms_time, text[] )
- {
- if(GetPVarInt(playerid, "InfoTDshown") != -1)
- {
- PlayerTextDrawHide( playerid, rInfoTDS[ playerid ] );
- KillTimer( GetPVarInt( playerid, "InfoTDshown" ) );
- }
- PlayerTextDrawSetString( playerid, rInfoTDS[ playerid ], text );
- PlayerTextDrawShow( playerid, rInfoTDS[ playerid ] );
- PlayerPlaySound( playerid, 1058, 0, 0, 0 );
- SetPVarInt( playerid, "InfoTDshown", SetTimerEx( "InfoTD_Hide", ms_time, false, "i", playerid ) );
- return ( 1 );
- }
- function TD_MSG( playerid, ms_time, text[] )
- {
- if(GetPVarInt(playerid, "InfoTDshown") != -1)
- {
- PlayerTextDrawHide( playerid, rInfoTDS[ playerid ] );
- KillTimer( GetPVarInt( playerid, "InfoTDshown" ) );
- }
- PlayerTextDrawSetString( playerid, rInfoTDS[ playerid ], text );
- PlayerTextDrawShow( playerid, rInfoTDS[ playerid ] );
- PlayerPlaySound( playerid, 1058, 0, 0, 0 );
- SetPVarInt( playerid, "InfoTDshown", SetTimerEx( "InfoTD_Hide", ms_time, false, "i", playerid ) );
- return ( 1 );
- }
- function InfoTD_Hide(playerid)
- {
- SetPVarInt( playerid, "InfoTDshown", -1 );
- PlayerTextDrawHide( playerid, rInfoTDS[ playerid ] );
- }
- stock GetName(playerid)
- {
- new pName[MAX_PLAYERS];
- GetPlayerName(playerid, pName, sizeof(pName));
- return pName;
- }
- stock SetPlayerPosEx(playerid, Float:X, Float:Y, Float:Z, Float:angle, interior, world)
- {
- SetPlayerPos(playerid, X, Y, Z);
- SetPlayerFacingAngle(playerid, angle);
- SetPlayerInterior(playerid, interior);
- SetPlayerVirtualWorld(playerid, world);
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment