From 6cf21783bf2bbc4d69a7f137b1ed7d779f5199f2 Mon Sep 17 00:00:00 2001 From: Crayder Date: Sun, 4 Oct 2015 02:16:25 -0400 Subject: [PATCH] Adds temporary vehicles (/tcar). Closes #17 --- filterscripts/tstudio/tsmain.pwn | 3 +- filterscripts/tstudio/vehicles.pwn | 55 ++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 1 deletion(-) diff --git a/filterscripts/tstudio/tsmain.pwn b/filterscripts/tstudio/tsmain.pwn index 97a61c4..e79a705 100644 --- a/filterscripts/tstudio/tsmain.pwn +++ b/filterscripts/tstudio/tsmain.pwn @@ -4756,6 +4756,7 @@ YCMD:thelp(playerid, arg[], help) {"Vehicles"}, {"{81181C} - General{FFFFFF}"}, + {"tcar"}, {"avmodcar"}, {"avsetspawn"}, {"avdeletecar"}, @@ -4779,7 +4780,7 @@ YCMD:thelp(playerid, arg[], help) {"avrz"}, {"avmirror"}, - {""},{""},{""},{""},{""},{""},{""},{""},{""}//,{""},{""},{""},{""},{""},{""},{""}, + {""},{""},{""},{""},{""},{""},{""},{""}//,{""},{""},{""},{""},{""},{""},{""},{""}, //{""},{""},{""},{""},{""},{""},{""},{""},{""},{""},{""},{""},{""},{""},{""},{""}, }, {//BINDS diff --git a/filterscripts/tstudio/vehicles.pwn b/filterscripts/tstudio/vehicles.pwn index 9c5df7e..16f093b 100644 --- a/filterscripts/tstudio/vehicles.pwn +++ b/filterscripts/tstudio/vehicles.pwn @@ -41,6 +41,8 @@ new Iterator:Cars; new CarData[MAX_EDIT_CARS][CARINFO]; new CurrVehicle[MAX_PLAYERS] = { -1, ... }; +static TempVehicle[MAX_PLAYERS] = { -1, ... }; +static bool:IsTempVehicle[MAX_VEHICLES] = { 0, ... }; static VehicleNames[212][] = { {"Landstalker"},{"Bravura"},{"Buffalo"},{"Linerunner"},{"Perrenial"},{"Sentinel"},{"Dumper"}, @@ -288,6 +290,21 @@ public OnVehiclePaintjob(playerid, vehicleid, paintjobid) public OnVehicleSpawn(vehicleid) { + if(IsTempVehicle[vehicleid]) + { + foreach(new i: Player) + { + if(vehicleid == TempVehicle[i]) + { + TempVehicle[i] = -1; + break; + } + } + IsTempVehicle[vehicleid] = false; + + DestroyVehicle(vehicleid); + } + foreach(new i : Cars) { if(CarData[i][CarID] == vehicleid) @@ -305,6 +322,44 @@ public OnVehicleSpawn(vehicleid) return 1; } +public OnPlayerStateChange(playerid, newstate, oldstate) +{ + if(oldstate == PLAYER_STATE_DRIVER && IsValidVehicle(TempVehicle[playerid])) + { + IsTempVehicle[TempVehicle[playerid]] = false; + DestroyVehicle(TempVehicle[playerid]); + TempVehicle[playerid] = -1; + } + return 1; +} + +YCMD:tcar(playerid, arg[], help) +{ + if(help) + { + SendClientMessage(playerid, STEALTH_ORANGE, "______________________________________________"); + SendClientMessage(playerid, STEALTH_GREEN, "Gives you a temporary vehicle."); + return 1; + } + + inline SelectModel(pid, dialogid, response, listitem, string:text[]) + { + #pragma unused listitem, dialogid, pid, text + if(response) + { + new Float:X, Float:Y, Float:Z, Float:R; + GetPlayerPos(playerid, X, Y, Z); + GetPlayerFacingAngle(playerid, R); + TempVehicle[playerid] = CreateVehicle(listitem+400, X, Y, Z, R, 0, 0, 1); + IsTempVehicle[TempVehicle[playerid]] = true; + return 1; + } + } + Dialog_ShowCallback(playerid, using inline SelectModel, DIALOG_STYLE_LIST, "Texture Studio", VehicleList, "Ok", "Cancel"); + + return 1; +} + YCMD:avselectcar(playerid, arg[], help) { if(help)