Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Includes:
- #include <a_samp>
- #include <YSI\y_iterate>
- #include <zcmd>
- // Macros:
- #define function%0(%1) \
- forward %0(%1); \
- public %0(%1)
- // Variables:
- new bool: Commanded[MAX_VEHICLES];
- new gVehicleNames[212][] = {
- "Landstalker", "Bravura", "Buffalo", "Linerunner", "Pereniel", "Sentinel", "Dumper", "Firetruck", "Trashmaster", "Stretch", "Manana",
- "Infernus", "Voodoo", "Pony", "Mule", "Cheetah", "Ambulance", "Leviathan", "Moonbeam", "Esperanto", "Taxi", "Washington", "Bobcat",
- "Mr Whoopee", "BF Injection", "Hunter", "Premier", "Enforcer", "Securicar", "Banshee", "Predator", "Bus", "Rhino", "Barracks",
- "Hotknife", "Trailer", "Previon", "Coach", "Cabbie", "Stallion", "Rumpo", "RC Bandit", "Romero", "Packer", "Monster", "Admiral",
- "Squalo", "Seasparrow", "Pizzaboy", "Tram", "Trailer", "Turismo", "Speeder", "Reefer", "Tropic", "Flatbed", "Yankee", "Caddy",
- "Solair", "Berkley's RC Van", "Skimmer", "PCJ-600", "Faggio", "Harley", "RC Baron", "RC Raider", "Glendale", "Oceanic",
- "Sanchez", "Sparrow", "Patriot", "Quad", "Coastguard", "Dinghy", "Hermes", "Sabre", "Rustler", "ZR3 50", "Walton", "Regina",
- "Comet", "BMX", "Burrito", "Camper", "Marquis", "Baggage", "Dozer", "Maverick", "News Chopper", "Rancher", "FBI Rancher",
- "Virgo", "Greenwood", "Jetmax", "Hotring", "Sandking", "Blista Compact", "Police Maverick", "Boxville", "Benson", "Mesa",
- "RC Goblin", "Hotring Racer", "Hotring Racer", "Bloodring Banger", "Rancher", "Super GT", "Elegant", "Journey", "Bike",
- "Mountain Bike", "Beagle", "Cropdust", "Stunt", "Tanker", "RoadTrain", "Nebula", "Majestic", "Buccaneer", "Shamal", "Hydra",
- "FCR-900", "NRG-500", "HPV1000", "Cement Truck", "Tow Truck", "Fortune", "Cadrona", "FBI Truck", "Willard", "Forklift", "Traktor",
- "Combine", "Feltzer", "Remington", "Slamvan", "Blade", "Freight", "Streak", "Vortex", "Vincent", "Bullet", "Clover", "Sadler",
- "Firetruck", "Hustler", "Intruder", "Primo", "Cargobob", "Tampa", "Sunrise", "Merit", "Utility", "Nevada", "Yosemite", "Windsor",
- "Monster", "Monster", "Uranus", "Jester", "Sultan", "Stratum", "Elegy", "Raindance", "RC Tiger", "Flash", "Tahoma", "Savanna",
- "Bandito", "Freight", "Trailer", "Kart", "Mower", "Duneride", "Sweeper", "Broadway", "Tornado", "AT-400", "DFT-30", "Huntley",
- "Stafford", "BF-400", "Newsvan", "Tug", "Trailer", "Emperor", "Wayfarer", "Euros", "Hotdog", "Club", "Trailer", "Trailer",
- "Andromeda", "Dodo", "RC Cam", "Launch", "Radiowoz", "Radiowoz", "Radiowoz", "Radiowoz", "Picador", "S.W.A.T. Van",
- "Alpha", "Phoenix", "Glendale", "Sadler", "Luggage Trailer", "Luggage Trailer", "Stair Trailer", "Boxville", "Farm Plow", "Utility Trailer"
- };
- // Static functions:
- stock RespawnUnusedVehicles() {
- new UsedVeh[MAX_VEHICLES] = {false, ...};
- foreach(new playerid: Player) {
- UsedVeh[GetPlayerVehicleID(playerid)] = true;
- }
- for(new vehicleid = 1; vehicleid != MAX_VEHICLES; vehicleid++) {
- if(UsedVeh[vehicleid]) continue;
- else if(Commanded[vehicleid]) return DestroyVehicle(vehicleid), Commanded[vehicleid] = false;
- SetVehicleToRespawn(vehicleid);
- }
- return true;
- }
- stock CreatePlayerVehicle(playerid, modelid) {
- new vehicle;
- new Float: Position[4];
- if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER) {
- vehicle = GetPlayerVehicleID(playerid);
- GetVehiclePos(vehicle, Position[0], Position[1], Position[2]);
- GetVehicleZAngle(vehicle, Position[3]);
- DestroyVehicle(vehicle);
- } else {
- GetPlayerPos(playerid, Position[0], Position[1], Position[2]);
- GetPlayerFacingAngle(playerid, Position[3]);
- }
- vehicle = AddStaticVehicle(modelid, Position[0], Position[1], Position[2] + 1, Position[3], -1, -1);
- LinkVehicleToInterior(vehicle, GetPlayerInterior(playerid));
- SetVehicleVirtualWorld(vehicle, GetPlayerVirtualWorld(playerid));
- SetVehicleNumberPlate(vehicle, PlayerName(playerid));
- PutPlayerInVehicle(playerid, vehicle, 0);
- Commanded[vehicle] = true;
- return true;
- }
- stock GetVehicleModelIDByName(vehiclename[]) {
- for(new i = 0; i < 211; i++) {
- if(strfind(gVehicleNames[i], vehiclename, true) != -1) return i + 400;
- }
- return -1;
- }
- stock delete_free_space(string[], character = ' ') {
- new len = strlen(string);
- if(len) {
- new begin = -1, end = len;
- while(string[++begin] == character) {}
- if(string[begin] == EOS) {
- string[0] = false;
- return true;
- }
- while(string[--end] == character) {}
- strmid(string, string, begin, end + 1, len + 1);
- }
- return true;
- }
- stock PlayerName(playerid) {
- new Name[MAX_PLAYER_NAME];
- GetPlayerName(playerid, Name, sizeof(Name));
- return Name;
- }
- stock SpawnVehicle_InfrontOfPlayer2(playerid, vehiclemodel, color1, color2) {
- new Float:x, Float:y, Float:z;
- new Float:facing;
- new Float:distance;
- GetPlayerPos(playerid, x, y, z);
- GetPlayerFacingAngle(playerid, facing);
- new Float:size_x, Float:size_y, Float:size_z;
- GetVehicleModelInfo(vehiclemodel, VEHICLE_MODEL_INFO_SIZE, size_x, size_y, size_z);
- distance = size_x + 0.5;
- x += (distance * floatsin(-facing, degrees));
- y += (distance * floatcos(-facing, degrees));
- facing += 90.0;
- if(facing > 360.0) facing -= 360.0;
- return CreateVehicle(vehiclemodel, x, y, z + (size_z * 0.25), facing, color1, color2, -1);
- }
- // Dynamic functions:
- function RespawnVehicles(vehicleid) {
- RespawnUnusedVehicles();
- SendClientMessageToAll(-1, "Auta stworzone za pomocą komendy /v zostały usunięte!");
- return true;
- }
- // Public functions:
- main() {
- SetTimer("RespawnVehicles", 15 * 60 * 1000, true);
- return false;
- }
- public OnPlayerCommandPerformed(playerid, cmdtext[], success) {
- new text[100];
- if(!success) {
- for(new veh; veh < sizeof(gVehicleNames); veh++) {
- if(strlen(cmdtext) > 2 && !strcmp(cmdtext[1], gVehicleNames[veh], true)) {
- new c_veh_model = veh + 400, message[128];
- new Float:f[3] = {0.0, 0.0, 0.0};
- if(IsPlayerInAnyVehicle(playerid)) {
- new local_vehid = GetPlayerVehicleID(playerid);
- GetVehicleVelocity(GetPlayerVehicleID(playerid), f[0], f[1], f[2]);
- DestroyVehicle(local_vehid);
- }
- new local_vehid = CreatePlayerVehicle(playerid, c_veh_model);
- PutPlayerInVehicle(playerid, local_vehid, 0);
- SetVehicleVelocity(local_vehid, f[0], f[1], f[2]);
- format(message, sizeof(message), "Tworzysz pojazd o nazwie \"%s\".", gVehicleNames[veh]);
- SendClientMessage(playerid, 0x99FF00AA, message);
- return true;
- }
- }
- }
- format(text, sizeof(text), "Na serwerze nie ma takiej komendy jak %s!", cmdtext), SendClientMessage(playerid, -1, text);
- printf("%s wpisuje komendę: %s", PlayerName(playerid), cmdtext);
- return true;
- }
- // Commands:
- CMD:v(playerid, params[]) {
- delete_free_space(params);
- if(isnull(params)) return SendClientMessage(playerid, -1, "Wpisz /v nazwa_pojazdu");
- else if(GetVehicleModelIDByName(params) != -1) CreatePlayerVehicle(playerid, GetVehicleModelIDByName(params));
- else return SendClientMessage(playerid, -1, "Zła nazwa pojazdu!");
- return true;
- }
- CMD:respawn(playerid) {
- (!IsPlayerAdmin(playerid)? SendClientMessage(playerid, -1, "Tą komendę może wpisać tylko Administrator!"): SendClientMessage(playerid, -1, "Auta stworzone za pomocą komendy /v zostały usunięte!"),
- RespawnUnusedVehicles());
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement