Skip to content

Commit

Permalink
Adds temporary vehicles (/tcar).
Browse files Browse the repository at this point in the history
Closes #17
  • Loading branch information
Crayder committed Oct 4, 2015
1 parent 4a7cacd commit 6cf2178
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 1 deletion.
3 changes: 2 additions & 1 deletion filterscripts/tstudio/tsmain.pwn
Original file line number Diff line number Diff line change
Expand Up @@ -4756,6 +4756,7 @@ YCMD:thelp(playerid, arg[], help)
{"Vehicles"},

{"{81181C} - General{FFFFFF}"},
{"tcar"},
{"avmodcar"},
{"avsetspawn"},
{"avdeletecar"},
Expand All @@ -4779,7 +4780,7 @@ YCMD:thelp(playerid, arg[], help)
{"avrz"},
{"avmirror"},

{""},{""},{""},{""},{""},{""},{""},{""},{""}//,{""},{""},{""},{""},{""},{""},{""},
{""},{""},{""},{""},{""},{""},{""},{""}//,{""},{""},{""},{""},{""},{""},{""},{""},
//{""},{""},{""},{""},{""},{""},{""},{""},{""},{""},{""},{""},{""},{""},{""},{""},
},
{//BINDS
Expand Down
55 changes: 55 additions & 0 deletions filterscripts/tstudio/vehicles.pwn
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ new Iterator:Cars<MAX_EDIT_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"},
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit 6cf2178

Please sign in to comment.