Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <sscanf2_5>
- #include <zcmd>
- #include <YSI/y_ini>
- #undef MAX_PLAYERS
- #define MAX_PLAYERS 20
- #define YOUR_SERVER_NAME "Plant the Bomb"
- #define YOUR_ACCOUNT_DIRECTORY "PTB/Accounts/%s.ini"
- //Leave .ini on the end - This is the extension and is vital!
- #define M1_NAME "Warehouse Rumble"
- #define M2_NAME "Bridge Takedown"
- #define BOMB_EXPLODE_TIME 30
- //This is in seconds.
- #define GetPlayerNameEx(%0,%1,%2) GetPlayerName(%0, %1, %2); for(new i = 0; i != %2; i ++) if(%1[i] == '_') %1[i] = ' '
- #define HOLDING(%0) \
- ((newkeys & (%0)) == (%0))
- #define PRESSED(%0) \
- (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
- #define c_CMD 0x4CB809FF
- #define c_ERROR 0xED2D07FF
- #define c_GENERAL 0x07ED91FF
- #define NOAUTH SendClientMessage(playerid, c_ERROR, "ERROR: You are not able to use that command!")
- #define d_JOIN1 1
- #define d_JOIN2 2
- #define d_REGISTER 3
- #define d_LOGIN 4
- #define d_RADIO 5
- enum pInfo
- {
- Passcode, //This is encoded as a number.
- Cash,
- Auth,
- Kills,
- Deaths,
- HighestKS
- }
- new p_Data[MAX_PLAYERS][pInfo];
- new
- TeamSkin[ 6 ], //We have 5 skins, 5 + \o (NULL) = 6.
- Text:TeamTD_0, // - 0 is the black box on class selection!
- Text:TeamTD_1, // - 1 is the Terrorist label!
- Text:TeamTD_2, // - 2 is the mission description!
- Text:TeamTD_3, // - 3 is the Counter Terrorist label!
- Text:TeamTD_4, // - 4 is the mission description!
- Text:BombOutline,
- Text:BombText,
- Text:BombS1,
- Text:BombS2,
- Text:BombS3
- ;
- new
- p_State[MAX_PLAYERS] = -1,
- /* There are 4 different nodes that this variable can have, they are listed below:
- 0: Class Select - Called when the player is selecting their class.
- 1: Not spawned - Connecting, Disconnecting(?)
- 2: Spectating - Player is currently spectating the battlefield.
- 3: Spawned - Player is currently spawned, killable, and spectatable.
- 4: Dead - Has been killed within the last (RESPAWN_DELAY) seconds. (RESPAWN_DELAY is configurable up top!)
- Using this method, we should be able to accurately detect what each players state is at any time.
- */
- p_ClassSelected[MAX_PLAYERS char] = -1,
- /*
- This is where the team character they selected is saved to their username until it is changed, so we can detect EVERY
- thing a player does.
- */
- p_ViewingDialog[MAX_PLAYERS] = -1,
- /*
- This stores the ID of the ID they are currently viewing, to give administrators an exact count on
- what a user is doing!
- */
- p_SelectedTeam[MAX_PLAYERS] = -1,
- /*
- Stores the Team ID of the selected player!
- Values:
- -1: None (Class selection? Bug?)
- 1: Terrorist
- 2: Counter Terrorist
- */
- bool: p_LoggedIn[MAX_PLAYERS char] = false,
- /* Values:
- 0: Not logged in
- 1: Logged in
- */
- p_KillStreak[MAX_PLAYERS] = 0,
- /*
- This value goes up +1 every time you get a kill, in intervals of 5, it broadcasts killstreak messages to the
- server.
- */
- p_LastKill[MAX_PLAYERS][MAX_PLAYER_NAME],
- /*
- Stores the name of your last killed player. When you join the server, this will reset to "None".
- */
- p_SpawnedVehicle[MAX_PLAYERS] = -1,
- /*
- Stores the vehicle ID of your spawned vehicle.
- Any value other than -1 means their spawned vehicle is.. well, spawned.
- */
- bool:p_FirstSpawn[MAX_PLAYERS] = true,
- /*
- Stores whether it's the users first spawn or not.
- If it is, we need to load the map's objects, and set them up;
- We could also send them a message!
- */
- bool:p_AnimationsLoaded[MAX_PLAYERS] = false,
- /*
- Stores whether the user has preloaded their animations or not.
- */
- bool:p_InsideBombZone[MAX_PLAYERS] = false,
- /*
- We use this to detect whether the user is inside of the bomb zone (also indicated by a checkpoint)
- Once they leave this checkpoint, their variable is set to false.
- */
- Float:p_PosInBombZone[MAX_PLAYERS][3],
- /*
- This is how we will check if they're still in the zone after each second passes.
- */
- g_SelectedMap = 1,
- /*
- Stores the ID of the map currently loaded.
- After server restart, this is automatically set to 1.
- */
- bool:g_BombPlanted = false,
- /*
- Used to detect whether the bomb has been detected or not.
- */
- bool:g_BombPlantSuccess = false,
- /*
- Used to detect whether they successfully planted the bomb!
- */
- g_BombTimer,
- g_BSeconds = 0
- ;
- new
- /*
- These are our randomized spawns to prevent Spawn Killing!
- X Y Z A
- */
- Float:M1_CT[][8] =
- {
- {-2141.2556, -268.6744, 40.7195, 90.9648},
- {-2145.7654, -257.3408, 40.7195, 178.1238},
- {-2189.1001, -268.6501, 40.7195, 269.7705},
- {-2187.5730, -257.4611, 40.7195, 269.1034},
- {-2187.3916, -256.4670, 40.7195, 266.0067},
- {-2184.8154, -264.8004, 36.5156, 269.6441},
- {-2184.6428, -262.3403, 36.5156, 268.2798}
- },
- Float:M1_TER[][8] =
- {
- {-2183.4485, -206.3433, 36.5156, 179.0283},
- {-2187.9800, -206.7578, 36.5156, 180.1499},
- {-2181.7295, -213.1991, 36.5156, 87.6640},
- {-2182.0408, -222.1220, 36.5156, 89.4396},
- {-2184.2075, -224.5078, 36.5156, 359.4396},
- {-2188.7322, -215.4334, 36.5156, 267.4650},
- {-2188.5605, -212.7593, 36.5156, 269.6089}
- }
- ;
- public OnGameModeInit()
- {
- SendRconCommand("hostname "YOUR_SERVER_NAME);
- new
- r_Map = random(2);
- //Allows for 2 maps.
- switch(r_Map)
- {
- case 0:
- {
- SetGameModeText(M1_NAME);
- }
- case 1:
- {
- SetGameModeText(M2_NAME);
- }
- }
- g_BombPlanted = false;
- //Terrorists!
- /*
- First: Find "new TeamSkin", and increase the array by the number of skins you want.
- Example: You have 12 skins, you need to have "new TeamSkin[13]" due to the NULL character at the end.
- TeamSkin[ # ] = AddPlayerClassEx ( TEAMID, SKINID, XPOS, YPOS, ZPOS, APOS, MELEEID, AMMO, SECONDARYID, AMMO, ASSAULTRIFLE, AMMO );
- */
- TeamSkin[ 0 ] = AddPlayerClassEx( 1, 0, 0, 0, 0, 0, 4, 1, 24, 100, 34, 100 );
- TeamSkin[ 1 ] = AddPlayerClassEx( 1, 1, 0, 0, 0, 0, 4, 1, 24, 100, 34, 100 );
- TeamSkin[ 2 ] = AddPlayerClassEx( 1, 299, 0, 0, 0, 0, 4, 1, 24, 100, 34, 100 );
- //Counter Terrorists!
- TeamSkin[ 3 ] = AddPlayerClassEx( 2, 284, 0, 0, 0, 0, 4, 1, 24, 100, 34, 100 );
- TeamSkin[ 4 ] = AddPlayerClassEx( 2, 285, 0, 0, 0, 0, 4, 1, 24, 100, 34, 100 );
- TeamSkin[ 5 ] = AddPlayerClassEx( 2, 286, 0, 0, 0, 0, 4, 1, 24, 100, 34, 100 );
- TeamTD_0 = TextDrawCreate(496.000000, 108.000000, "_~n~~n~~n~~n~~n~~n~~n~~n~");
- TextDrawBackgroundColor(TeamTD_0, 255);
- TextDrawFont(TeamTD_0, 1);
- TextDrawLetterSize(TeamTD_0, 0.500000, 1.000000);
- TextDrawColor(TeamTD_0, -1);
- TextDrawSetOutline(TeamTD_0, 0);
- TextDrawSetProportional(TeamTD_0, 1);
- TextDrawSetShadow(TeamTD_0, 1);
- TextDrawUseBox(TeamTD_0, 1);
- TextDrawBoxColor(TeamTD_0, 255);
- TextDrawTextSize(TeamTD_0, 630.000000, 0.000000);
- TeamTD_1 = TextDrawCreate(508.000000, 112.000000, "~r~Terrorist");
- TextDrawBackgroundColor(TeamTD_1, -1);
- TextDrawFont(TeamTD_1, 0);
- TextDrawLetterSize(TeamTD_1, 0.500000, 2.000000);
- TextDrawColor(TeamTD_1, 255);
- TextDrawSetOutline(TeamTD_1, 1);
- TextDrawSetProportional(TeamTD_1, 1);
- TeamTD_2 = TextDrawCreate(497.000000, 138.000000, "~y~Mission :~n~___~r~Destroy ~w~the ~y~target area!");
- TextDrawBackgroundColor(TeamTD_2, 255);
- TextDrawFont(TeamTD_2, 3);
- TextDrawLetterSize(TeamTD_2, 0.270000, 1.800000);
- TextDrawColor(TeamTD_2, -1);
- TextDrawSetOutline(TeamTD_2, 0);
- TextDrawSetProportional(TeamTD_2, 1);
- TextDrawSetShadow(TeamTD_2, 1);
- TeamTD_3 = TextDrawCreate(508.000000, 112.000000, "~b~Counter Terrorist");
- TextDrawBackgroundColor(TeamTD_3, -1);
- TextDrawFont(TeamTD_3, 0);
- TextDrawLetterSize(TeamTD_3, 0.500000, 2.000000);
- TextDrawColor(TeamTD_3, 255);
- TextDrawSetOutline(TeamTD_3, 1);
- TextDrawSetProportional(TeamTD_3, 1);
- TeamTD_4 = TextDrawCreate(497.000000, 138.000000, "~y~Mission :~n~___~b~Protect ~w~the ~y~target area!");
- TextDrawBackgroundColor(TeamTD_4, 255);
- TextDrawFont(TeamTD_4, 3);
- TextDrawLetterSize(TeamTD_4, 0.270000, 1.799999);
- TextDrawColor(TeamTD_4, -1);
- TextDrawSetOutline(TeamTD_4, 0);
- TextDrawSetProportional(TeamTD_4, 1);
- TextDrawSetShadow(TeamTD_4, 1);
- BombOutline = TextDrawCreate(140.000000, 410.000000, "_~n~_~n~_");
- TextDrawBackgroundColor(BombOutline, 255);
- TextDrawFont(BombOutline, 1);
- TextDrawLetterSize(BombOutline, 0.500000, 1.000000);
- TextDrawColor(BombOutline, -1);
- TextDrawSetOutline(BombOutline, 1);
- TextDrawSetProportional(BombOutline, 1);
- TextDrawUseBox(BombOutline, 1);
- TextDrawBoxColor(BombOutline, -1);
- TextDrawTextSize(BombOutline, 490.000000, 0.000000);
- BombText = TextDrawCreate(246.000000, 418.000000, "PLANTING BOMB...");
- TextDrawBackgroundColor(BombText, 255);
- TextDrawFont(BombText, 1);
- TextDrawLetterSize(BombText, 0.500000, 1.000000);
- TextDrawColor(BombText, -16776961);
- TextDrawSetProportional(BombText, 1);
- BombS1 = TextDrawCreate(140.000000, 410.000000, "_~n~_~n~_");
- TextDrawBackgroundColor(BombS1, 255);
- TextDrawFont(BombS1, 1);
- TextDrawLetterSize(BombS1, 0.500000, 1.000000);
- TextDrawColor(BombS1, -1);
- TextDrawSetOutline(BombS1, 0);
- TextDrawSetProportional(BombS1, 1);
- TextDrawSetShadow(BombS1, 1);
- TextDrawUseBox(BombS1, 1);
- TextDrawBoxColor(BombS1, 16777215);
- TextDrawTextSize(BombS1, 270.000000, 0.000000);
- BombS2 = TextDrawCreate(140.000000, 410.000000, "_~n~_~n~_");
- TextDrawBackgroundColor(BombS2, 255);
- TextDrawFont(BombS2, 1);
- TextDrawLetterSize(BombS2, 0.500000, 1.000000);
- TextDrawColor(BombS2, -1);
- TextDrawSetOutline(BombS2, 0);
- TextDrawSetProportional(BombS2, 1);
- TextDrawSetShadow(BombS2, 1);
- TextDrawUseBox(BombS2, 1);
- TextDrawBoxColor(BombS2, 16777215);
- TextDrawTextSize(BombS2, 380.000000, 0.000000);
- BombS3 = TextDrawCreate(140.000000, 410.000000, "_~n~_~n~_");
- TextDrawBackgroundColor(BombS3, 255);
- TextDrawFont(BombS3, 1);
- TextDrawLetterSize(BombS3, 0.500000, 1.000000);
- TextDrawColor(BombS3, -1);
- TextDrawSetOutline(BombS3, 0);
- TextDrawSetProportional(BombS3, 1);
- TextDrawSetShadow(BombS3, 1);
- TextDrawUseBox(BombS3, 1);
- TextDrawBoxColor(BombS3, 16777215);
- TextDrawTextSize(BombS3, 490.000000, 0.000000);
- return true;
- }
- main()
- {
- print("Created by 2KY for the SA:MP Community!");
- //Please leave these credits, even if it's only a print in your console window.
- }
- public OnPlayerConnect(playerid)
- {
- if(fexist(FindAccountPath(playerid)))
- {
- ShowPlayerDialog(playerid, d_JOIN2, DIALOG_STYLE_LIST, "{68C20E}Processing Center", "Login\nHow to Play\nCredits", "Select", "Quit"),
- p_ViewingDialog[playerid] = d_JOIN2;
- }
- else
- {
- ShowPlayerDialog(playerid, d_JOIN1, DIALOG_STYLE_LIST, "{68C20E}Processing Center", "Register\nHow to Play\nCredits", "Select", "Quit"),
- p_ViewingDialog[playerid] = d_JOIN1;
- }
- p_LastKill[playerid] = "None";
- p_State{playerid} = 1;
- return true;
- }
- public OnPlayerRequestClass(playerid, classid)
- {
- p_ClassSelected{playerid} = classid;
- p_State{playerid} = 0;
- ClearClassSelectionTextDraws(playerid);
- switch(p_ClassSelected{playerid}) {
- //Are they selecting a Terrorist Team Member? If so - Show them this!
- case 0..2: {
- TextDrawShowForPlayer(playerid, TeamTD_0);
- TextDrawShowForPlayer(playerid, TeamTD_1);
- TextDrawShowForPlayer(playerid, TeamTD_2);
- p_SelectedTeam[playerid] = 1;
- }
- //Are they selecting a Counter Terrorist Team Member? If so - Show them this!
- case 3..5: {
- TextDrawShowForPlayer(playerid, TeamTD_0);
- TextDrawShowForPlayer(playerid, TeamTD_3);
- TextDrawShowForPlayer(playerid, TeamTD_4);
- p_SelectedTeam[playerid] = 2;
- }
- }
- return 1;
- }
- public OnPlayerRequestSpawn(playerid)
- {
- if(p_LoggedIn{playerid} != true) { return 0; }
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- if(p_FirstSpawn[playerid] == true)
- {
- new
- p_Str[128];
- switch(g_SelectedMap)
- {
- case 1: //if g_SelectedMap equals 1..
- {
- format(p_Str, sizeof(p_Str), "You are currently playing: {1B42E0}%s!", M1_NAME);
- }
- case 2: //if g_SelectedMap equals 2.. and so on...
- {
- format(p_Str, sizeof(p_Str), "You are currently playing: {1B42E0}%s!", M2_NAME);
- }
- }
- SendClientMessage(playerid, -1, p_Str);
- if(p_AnimationsLoaded[playerid] == false)
- {
- PreloadAnimLib(playerid,"BOMBER"), PreloadAnimLib(playerid,"RAPPING");
- PreloadAnimLib(playerid,"SHOP"), PreloadAnimLib(playerid,"BEACH");
- PreloadAnimLib(playerid,"SMOKING"), PreloadAnimLib(playerid,"FOOD");
- PreloadAnimLib(playerid,"ON_LOOKERS"), PreloadAnimLib(playerid,"DEALER");
- PreloadAnimLib(playerid,"CRACK"), PreloadAnimLib(playerid,"CARRY");
- PreloadAnimLib(playerid,"COP_AMBIENT"), PreloadAnimLib(playerid,"PARK");
- PreloadAnimLib(playerid,"INT_HOUSE"), PreloadAnimLib(playerid,"FOOD");
- p_AnimationsLoaded[playerid] = true;
- }
- p_FirstSpawn[playerid] = false;
- }
- if(p_SelectedTeam[playerid] == 1) //Terrorist
- {
- new
- r_Spawn = random(sizeof(M1_TER));
- SetPlayerPos(playerid, M1_TER[r_Spawn][0], M1_TER[r_Spawn][1], M1_TER[r_Spawn][2]);
- SetPlayerFacingAngle(playerid, M1_TER[r_Spawn][3]);
- if(g_BombPlanted == false) {
- SetPlayerCheckpoint(playerid, -2182.5017, -247.4970, 36.5156, 3.0);
- }
- }
- if(p_SelectedTeam[playerid] == 2) //Counter Terrorist
- {
- new
- r_Spawn = random(sizeof(M1_CT));
- SetPlayerPos(playerid, M1_CT[r_Spawn][0], M1_CT[r_Spawn][1], M1_CT[r_Spawn][2]);
- SetPlayerFacingAngle(playerid, M1_CT[r_Spawn][3]);
- }
- ClearClassSelectionTextDraws(playerid);
- p_State{playerid} = 3;
- return true;
- }
- public OnPlayerDeath(playerid, killerid, reason)
- {
- new
- p_Name[MAX_PLAYER_NAME],
- d_Str[128],
- d_Name[MAX_PLAYER_NAME]
- ;
- GetPlayerNameEx(killerid, d_Name, 24);
- GetPlayerName(playerid, p_Name, 24);
- p_LastKill[killerid] = p_Name;
- p_KillStreak[killerid]++;
- p_KillStreak[playerid] = 0;
- if(p_KillStreak[killerid] > p_Data[killerid][HighestKS])
- {
- p_Data[killerid][HighestKS] = p_KillStreak[killerid];
- }
- switch(p_KillStreak[killerid])
- {
- case 5:
- {
- format(d_Str, sizeof(d_Str), "* %s has achieved a 5 killstreak!", d_Name);
- SendClientMessageToAll(c_GENERAL, d_Str);
- }
- case 10:
- {
- format(d_Str, sizeof(d_Str), "* %s has achieved a 10 killstreak!", d_Name);
- SendClientMessageToAll(c_GENERAL, d_Str);
- }
- case 15:
- {
- format(d_Str, sizeof(d_Str), "* %s has achieved a 15 killstreak!", d_Name);
- SendClientMessageToAll(c_GENERAL, d_Str);
- }
- case 20:
- {
- format(d_Str, sizeof(d_Str), "* %s has achieved a 20 killstreak!", d_Name);
- SendClientMessageToAll(c_GENERAL, d_Str);
- }
- case 25:
- {
- format(d_Str, sizeof(d_Str), "* %s has achieved a 25 killstreak!", d_Name);
- SendClientMessageToAll(c_GENERAL, d_Str);
- }
- case 30:
- {
- format(d_Str, sizeof(d_Str), "* %s has achieved a 30 killstreak!", d_Name);
- SendClientMessageToAll(c_GENERAL, d_Str);
- }
- case 35:
- {
- format(d_Str, sizeof(d_Str), "* %s has achieved a 35 killstreak!", d_Name);
- SendClientMessageToAll(c_GENERAL, d_Str);
- }
- case 40:
- {
- format(d_Str, sizeof(d_Str), "* %s has achieved a 40 killstreak!", d_Name);
- SendClientMessageToAll(c_GENERAL, d_Str);
- }
- case 45:
- {
- format(d_Str, sizeof(d_Str), "* %s has achieved a 45 killstreak!", d_Name);
- SendClientMessageToAll(c_GENERAL, d_Str);
- }
- case 50:
- {
- format(d_Str, sizeof(d_Str), "* %s has achieved a 50 killstreak!", d_Name);
- SendClientMessageToAll(c_GENERAL, d_Str);
- }
- }
- p_State{playerid} = 4;
- return true;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- if(p_LoggedIn{playerid} == true)
- {
- new
- INI:File = INI_Open(FindAccountPath(playerid));
- INI_SetTag( File, "data");
- INI_WriteInt( File, "Cash", GetPlayerMoney(playerid));
- INI_WriteInt( File, "Admin", p_Data[playerid][Auth]);
- INI_WriteInt( File, "Kills", p_Data[playerid][Kills]);
- INI_WriteInt( File, "Deaths", p_Data[playerid][Deaths]);
- INI_WriteInt( File, "HighestKS", p_Data[playerid][HighestKS]);
- INI_Close(File);
- if(p_SpawnedVehicle[playerid] != -1)
- {
- new
- p_Name[MAX_PLAYER_NAME];
- GetPlayerNameEx(playerid, p_Name, 24);
- printf("[p_SpawnedVehicle] %s (VID: %d) has been despawned. Reason: Disconnected.", p_Name, p_SpawnedVehicle[playerid]);
- DestroyVehicle(p_SpawnedVehicle[playerid]);
- p_SpawnedVehicle[playerid] = -1;
- }
- }
- p_LoggedIn{playerid} = false, p_State{playerid} = 1,
- p_SelectedTeam[playerid] = -1;
- return true;
- }
- forward LoadUser_data(playerid,name[],value[]);
- public LoadUser_data(playerid,name[],value[])
- {
- INI_Int( "Passcode", p_Data[playerid][Passcode]);
- INI_Int( "Cash", p_Data[playerid][Cash]);
- INI_Int( "Admin", p_Data[playerid][Auth]);
- INI_Int( "Kills", p_Data[playerid][Kills]);
- INI_Int( "Deaths", p_Data[playerid][Deaths]);
- INI_Int( "HighestKS", p_Data[playerid][HighestKS]);
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- switch( dialogid )
- {
- case d_JOIN1: //They're new to the server and click 'register'
- {
- switch(listitem)
- {
- case 0: //They're new to the server and click 'register'
- {
- ShowPlayerDialog(playerid, d_REGISTER, DIALOG_STYLE_PASSWORD, "{68C20E}Processing Center: Register", "{FFFFFF}Welcome to " YOUR_SERVER_NAME"!\nYou do not have an account on this server.\nPlease enter your password below to play!", "Register", ""),
- p_ViewingDialog[playerid] = d_REGISTER;
- }
- }
- }
- case d_JOIN2:
- {
- switch(listitem)
- {
- case 0: //They're returning users, and clicked 'login'
- {
- INI_ParseFile(FindAccountPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
- ShowPlayerDialog(playerid, d_LOGIN, DIALOG_STYLE_PASSWORD, "{68C20E}Processing Center: Authorize", "{FFFFFF}Welcome back to the server!\nIt appears as if you have been here before.\nPlease enter your password to continue!", "Login", ""),
- p_ViewingDialog[playerid] = d_LOGIN;
- }
- }
- }
- case d_REGISTER:
- {
- if( response ) //They clicked 'Select'
- {
- if(! strlen(inputtext)) //They just hit ENTER (RETURN) without entering a password.
- return ShowPlayerDialog(playerid, d_JOIN1, DIALOG_STYLE_LIST, "{68C20E}Processing Center", "Register\nHow to Play\nCredits", "Select", "Quit");
- new
- INI:p_Acc = INI_Open(FindAccountPath(playerid));
- INI_SetTag( p_Acc, "data");
- INI_WriteInt( p_Acc, "Passcode", udb_hash(inputtext));
- INI_WriteInt( p_Acc, "Cash", GetPlayerMoney(playerid));
- INI_WriteInt( p_Acc, "Admin", p_Data[playerid][Auth]);
- INI_WriteInt( p_Acc, "Kills", p_Data[playerid][Kills]);
- INI_WriteInt( p_Acc, "Deaths", p_Data[playerid][Deaths]);
- INI_WriteInt( p_Acc, "HighestKS", 0);
- INI_Close( p_Acc );
- SetPlayerPos(playerid, 150.2975, -64.9889, 1.5781);
- SetPlayerFacingAngle(playerid, 178.2798);
- SetPlayerCameraPos(playerid, 150.4190, -68.7553, 1.4297);
- SetPlayerCameraLookAt(playerid, 150.2975, -64.9889, 1.5781);
- TextDrawShowForPlayer(playerid, TeamTD_0);
- TextDrawShowForPlayer(playerid, TeamTD_1);
- TextDrawShowForPlayer(playerid, TeamTD_2);
- p_LoggedIn{playerid} = true;
- p_ViewingDialog[playerid] = -1;
- }
- else return p_ViewingDialog[playerid] = -1, Kick(playerid);
- }
- case d_LOGIN:
- {
- if( response )
- {
- if(udb_hash(inputtext) == p_Data[playerid][Passcode])
- {
- INI_ParseFile(FindAccountPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
- GivePlayerMoney(playerid, p_Data[playerid][Cash]);
- p_LoggedIn{playerid} = true;
- p_ViewingDialog[playerid] = -1;
- SetPlayerPos(playerid, 150.2975, -64.9889, 1.5781);
- SetPlayerFacingAngle(playerid, 178.2798);
- SetPlayerCameraPos(playerid, 150.4190, -68.7553, 1.4297);
- SetPlayerCameraLookAt(playerid, 150.2975, -64.9889, 1.5781);
- TextDrawShowForPlayer(playerid, TeamTD_0);
- TextDrawShowForPlayer(playerid, TeamTD_1);
- TextDrawShowForPlayer(playerid, TeamTD_2);
- }
- else return ShowPlayerDialog(playerid, d_LOGIN, DIALOG_STYLE_PASSWORD, "{68C20E}Processing Center: Authorize", "{FFFFFF}Incorrect password!\nPlease enter your password to continue!", "Login", ""), p_ViewingDialog[playerid] = d_LOGIN;
- }
- else return p_ViewingDialog[playerid] = -1, Kick(playerid);
- }
- case d_RADIO:
- {
- if(response)
- {
- switch(listitem)
- {
- case 0: //Alternative Rock
- {
- PlayAudioStreamForPlayer(playerid, "http://stream.radioactivity.fm:8002/");
- SendClientMessage(playerid, c_GENERAL, "> You are now listening to 99.1 FM - WIKD Eagles!");
- }
- case 1: //Best of the 80s
- {
- PlayAudioStreamForPlayer(playerid, "http://scfire-mtc-aa05.stream.aol.com:80/stream/1013/");
- SendClientMessage(playerid, c_GENERAL, "> You are now listening to SKY.FM - Best of the 80s!");
- }
- }
- SendClientMessage(playerid, c_ERROR, "NOTE: In order to even START the stream - Your GTA radio volume has to be on!");
- }
- else return StopAudioStreamForPlayer(playerid);
- }
- }
- return 1;
- }
- public OnPlayerEnterCheckpoint(playerid)
- {
- if(g_BSeconds == 0) {
- p_InsideBombZone[playerid] = true;
- SendClientMessage(playerid, -1, "true");
- }
- return 1;
- }
- public OnPlayerLeaveCheckpoint(playerid)
- {
- p_InsideBombZone[playerid] = false;
- SendClientMessage(playerid, -1, "false");
- return 1;
- }
- public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
- {
- if(PRESSED(KEY_SECONDARY_ATTACK))
- {
- if(p_InsideBombZone[playerid] == true && g_BombPlanted == false) //Checks if their inside of the bomb zone, and it's not planted already!
- {
- if(p_SelectedTeam[playerid] == 1) { //Probably shouldn't let the counter terrorists plant the bomb..
- new
- Float:Pos[3];
- GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
- p_PosInBombZone[playerid][0] = Pos[0], p_PosInBombZone[playerid][1] = Pos[1], p_PosInBombZone[playerid][2] = Pos[2];
- ApplyAnimation(playerid, "BOMBER", "BOM_Plant", 4.0, 0, 0, 0, 0, 0);
- g_BombTimer = SetTimerEx("PlantBomb", 1000, true, "i", playerid);
- }
- else return 0;
- }
- }
- return 1;
- }
- forward PlantBomb(playerid);
- public PlantBomb(playerid)
- {
- new
- Float:Pos[3]
- ;
- GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
- //if(p_PosInBombZone[playerid][0] == Pos[0] && p_PosInBombZone[playerid][1] == Pos[1] && p_PosInBombZone[playerid][2] == Pos[2])
- //{
- if(p_InsideBombZone[playerid] == true)
- {
- //SendClientMessage(playerid, c_ERROR, "u inside bomb zone jes");
- switch(g_BSeconds)
- {
- case 0:
- {
- TextDrawShowForPlayer(playerid, BombOutline),
- TextDrawShowForPlayer(playerid, BombText);
- g_BSeconds++;
- }
- case 1:
- {
- TextDrawShowForPlayer(playerid, BombS1);
- g_BSeconds++;
- }
- case 2:
- {
- TextDrawShowForPlayer(playerid, BombS2);
- g_BSeconds++;
- }
- case 3:
- {
- new
- p_Name[24],
- p_Str[128]
- ;
- TextDrawShowForPlayer(playerid, BombS3);
- ClearAnimations(playerid);
- g_BSeconds = 0;
- g_BombPlantSuccess = true;
- g_BombPlanted = true;
- TextDrawHideForPlayer(playerid, BombOutline), TextDrawHideForPlayer(playerid, BombText);
- TextDrawHideForPlayer(playerid, BombS1), TextDrawHideForPlayer(playerid, BombS2);
- TextDrawHideForPlayer(playerid, BombS3);
- GameTextForAll("~r~Bomb Planted!", 3000, 1);
- GetPlayerNameEx(playerid, p_Name, 24);
- format(p_Str, sizeof(p_Str), "< %s has planted the bomb!", p_Name);
- SendClientMessageToAll(c_GENERAL, p_Str);
- ClearAnimations(playerid);
- KillTimer(g_BombTimer);
- SetTimer("g_BombExplode", BOMB_EXPLODE_TIME*1000, false);
- for(new i; i < MAX_PLAYERS; i++)
- {
- switch(p_SelectedTeam[i])
- {
- case 1:
- {
- DisablePlayerCheckpoint(i);
- SendClientMessage(i, c_GENERAL, "MISSION: {FFFFFF}Defend the bomb!");
- }
- case 2:
- {
- SetPlayerCheckpoint(playerid, -2182.5017, -247.4970, 36.5156, 3.0);
- SendClientMessage(i, c_GENERAL, "MISSION: {FFFFFF}Defuse the bomb!");
- }
- }
- }
- }
- }
- }
- else //They moved!
- {
- KillTimer(g_BombTimer), g_BSeconds = 0;
- TextDrawHideForPlayer(playerid, BombOutline), TextDrawHideForPlayer(playerid, BombText);
- TextDrawHideForPlayer(playerid, BombS1);
- TextDrawHideForPlayer(playerid, BombS2);
- TextDrawHideForPlayer(playerid, BombS3);
- g_BombPlanted = false;
- g_BombPlantSuccess = false;
- return 1;
- }
- return 1;
- }
- forward g_BombExplode();
- public g_BombExplode()
- {
- if(g_BombPlantSuccess == true)
- {
- CreateExplosion(-2182.5017, -247.4970, 36.5156, 0, 50.0);
- for(new i; i < MAX_PLAYERS; i++)
- {
- switch(p_SelectedTeam[i])
- {
- case 1:
- {
- SendClientMessage(i, c_GENERAL, "MISSION SUCCESSFUL! +$1000");
- GameTextForPlayer(i, "~w~Mission ~b~successful!", 3000, 3);
- GivePlayerMoney(i, 1000);
- }
- case 2:
- {
- SendClientMessage(i, c_ERROR, "MISSION FAIL! -$100");
- GameTextForPlayer(i, "~w~Mission ~r~failure!", 3000, 3);
- GivePlayerMoney(i, -100);
- }
- }
- }
- g_BombPlanted = false;
- SetTimer("MapSwitch", 3000, false);
- }
- return 1;
- }
- forward MapSwitch();
- public MapSwitch()
- {
- for(new i; i < MAX_PLAYERS; i++)
- {
- SetPlayerHealth(i, 0.0);
- }
- return 1;
- }
- stock ClearClassSelectionTextDraws(playerid)
- {
- TextDrawHideForPlayer(playerid, TeamTD_0);
- TextDrawHideForPlayer(playerid, TeamTD_1);
- TextDrawHideForPlayer(playerid, TeamTD_2);
- TextDrawHideForPlayer(playerid, TeamTD_3);
- TextDrawHideForPlayer(playerid, TeamTD_4);
- return 1;
- }
- stock GetPlayerScriptState(playerid)
- {
- new
- p_StateName[32];
- switch(p_State{playerid})
- {
- case 0: { p_StateName = "Class Selection"; }
- case 1: { p_StateName = "Not Spawned"; }
- case 2: { p_StateName = "Spectating"; }
- case 3: { p_StateName = "Spawned"; }
- case 4: { p_StateName = "Dead"; }
- }
- return p_StateName;
- }
- stock FindAccountPath(playerid)
- {
- new
- string[128],
- p_Name[MAX_PLAYER_NAME]
- ;
- GetPlayerName(playerid, p_Name, sizeof(p_Name));
- format(string, sizeof(string), YOUR_ACCOUNT_DIRECTORY, p_Name);
- return string;
- }
- stock udb_hash(buf[]) { //Credits to Dracoblue
- new length=strlen(buf);
- new s1 = 1;
- new s2 = 0;
- new n;
- for (n=0; n<length; n++)
- {
- s1 = (s1 + buf[n]) % 65521;
- s2 = (s2 + s1) % 65521;
- }
- return (s2 << 16) + s1;
- }
- stock GetPlayerTitle(playerid)
- {
- new
- a_Title[64];
- switch(p_Data[playerid][Auth])
- {
- case 0: {
- a_Title = "Player";
- }
- case 1: {
- a_Title = "Moderator";
- }
- case 2: {
- a_Title = "Administrator";
- }
- }
- return a_Title;
- }
- PreloadAnimLib(playerid, animlib[]) { ApplyAnimation(playerid,animlib,"null",0.0,0,0,0,0,0); }
- /* NORMAL PLAYER COMMANDS */
- CMD:stats(playerid, params[])
- {
- new
- p_StatStr[128],
- u_ID,
- u_Name[MAX_PLAYER_NAME]
- ;
- if(sscanf(params, "u", u_ID)) //They JUST typed '/stats'
- {
- SendClientMessage(playerid, c_GENERAL, "[ - YOUR STATISTICS - ]");
- if(p_Data[playerid][Kills] > 0) {
- format(p_StatStr, sizeof(p_StatStr), "{FFFFFF}* Kills: %d, Deaths: %d, K/D Ratio: %0.2f", p_Data[playerid][Kills], p_Data[playerid][Deaths], floatdiv(p_Data[playerid][Kills], p_Data[playerid][Deaths]));
- }
- else if(p_Data[playerid][Kills] == 0) {
- format(p_StatStr, sizeof(p_StatStr), "{FFFFFF}* Kills: %d, Deaths: %d, K/D Ratio: 0.00", p_Data[playerid][Kills], p_Data[playerid][Deaths]);
- }
- SendClientMessage(playerid, -1, p_StatStr);
- format(p_StatStr, sizeof(p_StatStr), "{FFFFFF}* Current Killstreak: %d, Highest Killstreak: %d, Last Kill: %s", p_KillStreak[playerid], p_Data[playerid][HighestKS], p_LastKill[playerid]);
- return SendClientMessage(playerid, -1, p_StatStr);
- }
- //They typed in a User ID after the command, EG: '/stats 0' would retrieve ID 0's stats.
- GetPlayerNameEx(u_ID, u_Name, 24);
- format(p_StatStr, sizeof(p_StatStr), "[ - %s STATISTICS - ]", u_Name);
- SendClientMessage(playerid, c_GENERAL, p_StatStr);
- if(p_Data[u_ID][Kills] > 0) {
- format(p_StatStr, sizeof(p_StatStr), "{FFFFFF}* Kills: %d, Deaths: %d, K/D Ratio: %0.2f", p_Data[u_ID][Kills], p_Data[u_ID][Deaths], floatdiv(p_Data[u_ID][Kills], p_Data[u_ID][Deaths]));
- }
- else if(p_Data[playerid][Kills] == 0) {
- format(p_StatStr, sizeof(p_StatStr), "{FFFFFF}* Kills: %d, Deaths: %d, K/D Ratio: 0.00", p_Data[u_ID][Kills], p_Data[u_ID][Deaths]);
- }
- SendClientMessage(playerid, -1, p_StatStr);
- format(p_StatStr, sizeof(p_StatStr), "{FFFFFF}* Current Killstreak: %d, Highest Killstreak: %d, Last Kill: %s", p_KillStreak[u_ID], p_Data[u_ID][HighestKS], p_LastKill[u_ID]);
- return SendClientMessage(playerid, -1, p_StatStr);
- }
- CMD:music(playerid, params[])
- {
- return ShowPlayerDialog(playerid, d_RADIO, DIALOG_STYLE_LIST, "Please select a Radio Station!", "Alternative Rock\nBest of the 80s", "Select", "Stop");
- }
- /* MODERATOR COMMANDS */
- CMD:check(playerid, params[])
- {
- new
- p_ID;
- if(sscanf(params, "u", p_ID))
- return SendClientMessage(playerid, c_CMD, "< /check <Player ID>");
- if(!IsPlayerConnected(p_ID))
- return SendClientMessage(playerid, c_ERROR, "< /check - Player is not connected!");
- if(p_Data[playerid][Auth] >= 1)
- {
- new
- p_Str[128],
- p_Name[MAX_PLAYER_NAME]
- ;
- GetPlayerNameEx(p_ID, p_Name, sizeof(p_Name));
- format(p_Str, sizeof(p_Str), "-- [ Player %s : Check ] --", p_Name);
- SendClientMessage(playerid, c_GENERAL, p_Str);
- new
- d_Name[32],
- p_Weapons[13][2],
- p_WeaponName[32]
- ;
- if(p_ViewingDialog[p_ID] == -1) { d_Name = "None"; }
- else if(p_ViewingDialog[p_ID] == d_JOIN1) { d_Name = "Join (REGISTER)"; }
- else if(p_ViewingDialog[p_ID] == d_JOIN2) { d_Name = "Join (LOGIN)"; }
- else if(p_ViewingDialog[p_ID] == d_REGISTER) { d_Name = "Registration"; }
- else if(p_ViewingDialog[p_ID] == d_LOGIN) { d_Name = "Authorization"; }
- else if(p_ViewingDialog[p_ID] == d_RADIO) { d_Name = "Radio Selection"; }
- for (new i = 0; i < 13; i++)
- {
- GetPlayerWeaponData(p_ID, i, p_Weapons[i][0], p_Weapons[i][1]);
- }
- SendClientMessage(playerid, c_GENERAL, "- Weapons:");
- if(p_Weapons[1][0] != 0) { //Melee weapons
- GetWeaponName(p_Weapons[1][0], p_WeaponName, 32);
- format(p_Str, sizeof(p_Str), " * Melee: %s", p_WeaponName), SendClientMessage(playerid, -1, p_Str);
- }
- if(p_Weapons[2][0] != 0) { //Pistols
- GetWeaponName(p_Weapons[2][0], p_WeaponName, 32);
- format(p_Str, sizeof(p_Str), " * Pistol: %s [Ammo: %d]", p_WeaponName, p_Weapons[2][1]), SendClientMessage(playerid, -1, p_Str);
- }
- if(p_Weapons[3][0] != 0) { //Shotguns
- GetWeaponName(p_Weapons[3][0], p_WeaponName, 32);
- format(p_Str, sizeof(p_Str), " * Shotgun: %s [Ammo: %d]", p_WeaponName, p_Weapons[3][1]), SendClientMessage(playerid, -1, p_Str);
- }
- if(p_Weapons[4][0] != 0) { //SMGs
- GetWeaponName(p_Weapons[4][0], p_WeaponName, 32);
- format(p_Str, sizeof(p_Str), " * SMG: %s [Ammo: %d]", p_WeaponName, p_Weapons[4][1]), SendClientMessage(playerid, -1, p_Str);
- }
- if(p_Weapons[5][0] != 0) { //Assault Rifles
- GetWeaponName(p_Weapons[5][0], p_WeaponName, 32);
- format(p_Str, sizeof(p_Str), " * Assault Rifle: %s [Ammo: %d]", p_WeaponName, p_Weapons[5][1]), SendClientMessage(playerid, -1, p_Str);
- }
- if(p_Weapons[6][0] != 0) {
- GetWeaponName(p_Weapons[6][0], p_WeaponName, 32);
- format(p_Str, sizeof(p_Str), " * Rifle: %s [Ammo: %d]", p_WeaponName, p_Weapons[6][1]), SendClientMessage(playerid, -1, p_Str);
- }
- if(p_Weapons[7][0] != 0) {
- GetWeaponName(p_Weapons[7][0], p_WeaponName, 32);
- format(p_Str, sizeof(p_Str), " * {ED2D07}Forbidden Weapon: %s [Ammo: %d]", p_WeaponName, p_Weapons[7][1]), SendClientMessage(playerid, -1, p_Str);
- format(p_Str, sizeof(p_Str), "[ANTI2K] Forbidden weapon detected on %s, banning player...", p_Name);
- SendClientMessageToAll(c_ERROR, p_Str);
- BanEx(p_ID, "Weapon Hacks");
- }
- format(p_Str, sizeof(p_Str), "- Opened dialog: {FFFFFF}%s", d_Name), SendClientMessage(playerid, c_GENERAL, p_Str);
- return format(p_Str, sizeof(p_Str), "- Detected state: {FFFFFF}%s", GetPlayerScriptState(p_ID)), SendClientMessage(playerid, c_GENERAL, p_Str);
- }
- else return NOAUTH;
- }
- CMD:kick(playerid, params[])
- {
- if(p_Data[playerid][Auth] >= 1)
- {
- new
- p_ID,
- a_Reason[64],
- p_Str[128],
- a_Name[MAX_PLAYER_NAME],
- p_Name[MAX_PLAYER_NAME]
- ;
- if(sscanf(params, "iS()[64]", p_ID, a_Reason))
- return SendClientMessage(playerid, c_CMD, "< /kick <Player ID> <Reason[Optional]>");
- GetPlayerNameEx(playerid, a_Name, 24);
- GetPlayerNameEx(p_ID, p_Name, 24);
- if(!a_Reason[0]) { //They didn't enter a reason..
- format(p_Str, sizeof(p_Str), "{1B42E0}KICK: {FFFFFF}%s %s has booted %s from the server.", GetPlayerTitle(playerid), a_Name, p_Name);
- printf("[Kick] %s has been booted from the server by %s %s", p_Name, GetPlayerTitle(playerid), a_Name);
- }
- else { //They entered a reason..
- if(strlen(a_Reason) > 64) return SendClientMessage(playerid, c_ERROR, "< /kick - Please shorten the 'reason' parameter.");
- format(p_Str, sizeof(p_Str), "{1B42E0}KICK: {FFFFFF}%s %s has booted %s from the server, Reason: {1B42E0}%s", GetPlayerTitle(playerid), a_Name, p_Name, a_Reason);
- printf("[Kick] %s has been booted from the server by %s %s,", p_Name, GetPlayerTitle(playerid), a_Name);
- printf("\tReason: %s", a_Reason);
- }
- SendClientMessageToAll(-1, p_Str);
- return Kick(p_ID);
- }
- else return NOAUTH;
- }
- /* ADMINISTRATOR COMMANDS */
- CMD:spawnvehicle(playerid, params[])
- {
- new
- v_ID,
- v_COL1,
- v_COL2
- ;
- if(sscanf(params, "iI(0)I(0)", v_ID, v_COL1, v_COL2))
- return SendClientMessage(playerid, c_CMD, "< /spawnvehicle <Vehicle ID> <Col. 1[Optional]> <Col. 2[Optional]>");
- if(p_Data[playerid][Auth] == 2)
- {
- if(p_SpawnedVehicle[playerid] != -1) {
- SendClientMessage(playerid, c_CMD, "< Your previously spawned vehicle has been despawned.");
- DestroyVehicle(p_SpawnedVehicle[playerid]);
- p_SpawnedVehicle[playerid] = -1;
- }
- new
- v_Str[128],
- Float:p_Pos[4]
- ;
- GetPlayerPos(playerid, p_Pos[0], p_Pos[1], p_Pos[2]);
- GetPlayerFacingAngle(playerid, p_Pos[3]);
- p_SpawnedVehicle[playerid] = CreateVehicle(v_ID, p_Pos[0], p_Pos[1], p_Pos[2], p_Pos[3], v_COL1, v_COL2, 60000);
- PutPlayerInVehicle(playerid, p_SpawnedVehicle[playerid], 0);
- format(v_Str, sizeof(v_Str), "< You have spawned a vehicle. (INFO) Model: %d | Vehicle ID: %d | COLOR 1: %d | COLOR 2: %d", v_ID, GetPlayerVehicleID(playerid), v_COL1, v_COL2);
- return SendClientMessage(playerid, c_GENERAL, v_Str);
- }
- else return NOAUTH;
- }
- CMD:ban(playerid, params[])
- {
- if(p_Data[playerid][Auth] == 2)
- {
- new
- p_ID,
- p_Str[128],
- p_Name[MAX_PLAYER_NAME],
- a_Reason[64],
- a_Name[MAX_PLAYER_NAME]
- ;
- if(sscanf(params, "uS()[64]", p_ID, a_Reason))
- return SendClientMessage(playerid, c_CMD, "< /ban <Player ID> <Reason>");
- GetPlayerNameEx(playerid, a_Name, 24);
- GetPlayerNameEx(p_ID, p_Name, 24);
- if(strlen(a_Reason) > 64) return SendClientMessage(playerid, c_ERROR, "< /ban - Please shorten the 'reason' parameter.");
- format(p_Str, sizeof(p_Str), "{1B42E0}BAN: {FFFFFF}%s %s has banished %s from the server, Reason: {1B42E0}%s", GetPlayerTitle(playerid), a_Name, p_Name, a_Reason);
- printf("[Ban] %s has been banished from the server by %s %s,", p_Name, GetPlayerTitle(playerid), a_Name);
- printf("\t Reason: %s", a_Reason);
- return BanEx(p_ID, a_Reason);
- }
- else return NOAUTH;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement