Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <core>
- #include <float>
- /*
- Commands - /baitcar
- Requirements - You are a member of the SASD or LSPD, you are over rank 6.#
- Information - You go to a car you privately own or have a set of duplicate keys to. You park the vehicle, use /baitcar and then exit it.
- You then wait for a criminal to break into the car and steal it. When he is driving the person who used the /baitcar command can use it again, turning the car's engine off and locking the doors
- by freezing the player in place. /exitcar and other unfreezing methods should be unavailable at this time. To unlock the doors and let the criminals out or arrest them just use the /lock command on the car.
- It will unlock the car, unfreezing the suspects.
- This can work on more than one person in the same car.
- */
- // Don't add, for testing purposes
- enum pInfo
- {
- Faction,
- Rank,
- DupKeys,
- CarKeys
- };
- enum vInfo
- {
- Engine,
- Locked
- };
- new PlayerInfo[MAX_PLAYERS][pInfo];
- new VehicleInfo[MAX_VEHICLES][vInfo];
- // End of "Don't Add" list
- new VehicleBaited[MAX_VEHICLES]; // Temp vehicle cach
- main()
- {
- print("\n----------------------------------");
- print(" Baitcar Script - Made by Giacomand\n");
- print("----------------------------------\n");
- }
- public OnPlayerConnect(playerid)
- {
- // Don't add these - Testing Purposes
- GameTextForPlayer(playerid,"~w~SA-MP: ~r~Bare Script",5000,5);
- PlayerInfo[playerid][Faction] = 1; // We're a cop now
- PlayerInfo[playerid][Rank] = 1; // We're the Chief of Police, woot!
- PlayerInfo[playerid][CarKeys] = 1; // We got vehicle 1's carkeys.
- PlayerInfo[playerid][DupKeys] = -1; // Nothing
- SendClientMessage(playerid, 0xFFFFFFAA, "You were made The Chief of Police. (Rank 6 and over)");
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- if(!strcmp(cmdtext, "/baitcar"))
- {
- if((PlayerInfo[playerid][Faction] == 1 || PlayerInfo[playerid][Faction] == 6) && (PlayerInfo[playerid][Rank] <= 6)) // LSPD faction and SASD
- {
- if(GetPVarInt(playerid, "UsedBaitCar") == 1)
- {
- new vehicleidG;
- for(new i = 0; i < MAX_PLAYERS; i++)
- {
- vehicleidG = GetPlayerVehicleID(i);
- if(VehicleBaited[vehicleidG] >= 1)
- {
- TogglePlayerControllable(i, 0);
- SendClientMessage(i, 0xFF0000AA, "The Engine turns off and the doors are locked. The windows are strongly made and hard to break. To get out you need the keys.");
- // Don't want to stop here because there could be passengers in the car.
- }
- }
- VehicleInfo[vehicleidG][Locked] = 1; // Sets the car to locked.
- VehicleInfo[vehicleidG][Engine] = 1; // Sets the car's engine off. If the robbers don't have the keys then they can't turn it back on.
- SendClientMessage(playerid, 0xFF0000AA, "The car has been disabled. To get the suspects out you must unlock the car.");
- SetPVarInt(playerid, "UsedBaitCar", 0);
- }
- else if (IsPlayerInAnyVehicle(playerid))
- {
- new vehicleidG = GetPlayerVehicleID(playerid);
- if(PlayerInfo[playerid][CarKeys] == vehicleidG || PlayerInfo[playerid][DupKeys] == vehicleidG)
- {
- VehicleBaited[vehicleidG] = playerid+1;
- SetPVarInt(playerid, "UsedBaitCar", 1);
- SendClientMessage(playerid, 0xFFFFFFAA, "The car is now baited. Use /baitcar again to stop the car's engine and lock the people inside.");
- SendClientMessage(playerid, 0xFFFFFFAA, "To allow the suspect(s) to exit just open the car with the /lock command, it'll allow them to /exitcar and engine.");
- }
- else
- {
- SendClientMessage(playerid, 0xFF0000AA, "Get into a car you own or have the keys to (Duplicated).");
- }
- }
- else
- {
- SendClientMessage(playerid, 0xFF0000AA, "Get into a car you own or have the keys to (Duplicated).");
- }
- }
- else
- {
- SendClientMessage(playerid, 0xFF0000AA, "You're not a cop of any department or you aren't rank 6 and above.");
- }
- }
- {
- if(!strcmp(cmdtext, "/lock"))
- {
- //if near car, blablabla
- new vehicleid; // remove this when adding to script, I'm just using it to remove error since it's not in the LS-RP script.
- if(VehicleBaited[vehicleid] >= 1) // Should be on top before all commands. The vehicleid is the intergar that you collected by checking for nearby cars.
- {
- if(PlayerInfo[playerid][CarKeys] == vehicleid || PlayerInfo[playerid][DupKeys] == vehicleid) // Anyone with the keys can use this.
- {
- for(new i = 0; i < MAX_PLAYERS; i++)
- {
- if(GetPlayerVehicleID(i) == vehicleid)
- {
- TogglePlayerControllable(i, 1);
- SendClientMessage(i, 0xFFFFFFAA, "The door is now unlocked are you are free to exit.");
- // Don't end yet because there might be passengers.
- }
- }
- VehicleBaited[vehicleid] = -1; // Unbaited
- }
- else
- {
- SendClientMessage(playerid, 0xFF0000AA, "You need the keys to the car or duplicates.");
- }
- }
- // Place the rest of the lock command here.
- }
- return 0;
- }
- }
- // Use this function in the commands which could unfreeze the player. Such as /exitcar and /engine.
- //if(CheckBaited(playerid, vehicleid) == true) return 0;
- stock CheckBaited(playerid, vehicleid)
- {
- if(VehicleBaited[vehicleid] >= 1)
- {
- SendClientMessage(playerid, 0xFF0000AA, "The doors are locked and the engine is disabled");
- return true;
- }
- return false;
- }
- public OnPlayerSpawn(playerid)
- {
- SetPlayerInterior(playerid, 0);
- SetPlayerPos(playerid, 0.0, 0.0, 10.0);
- return 1;
- }
- public OnPlayerDeath(playerid, killerid, reason)
- {
- return 1;
- }
- public OnGameModeInit()
- {
- SetGameModeText("Bare Script");
- AddStaticVehicle(451, 0.0, 5.0, 10.0, 0.0, 0, 60); // For testing, this will be vehicle 0, we cannot use this as we don't own this car.
- AddStaticVehicle(451, 0.0, -5.0, 10.0, 0.0, 0, 60); // For testing, this will be vehicle 1, we can use for /baitcar since we privately own it.
- AddPlayerClass(265,0.0, 0.0, 0.0, 0.0,0,0,0,0,-1,-1);
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment