// This is a comment
// uncomment the line below if you want to write a filterscript
//#define FILTERSCRIPT
#define FILTERSCRIPT
#if defined FILTERSCRIPT
#include <a_samp>
#include <sscanf2>
#include <YSI\y_ini>
#include <YSI\y_inline>
#include <YSI\y_commands> // or zcmd
enum InfoVehicles
{
vehicle,
model,
world,
interior,
Float:angle,
Float:x_,
Float:y_,
Float:z_
};
new vInfo[MAX_PLAYERS][InfoVehicles];
public OnPlayerConnect(playerid)
{
if(fexist(FolderVehicles(playerid)))
{
inline loadvehicle(string:name[], string:value[])
{
INI_Int("model", vInfo[playerid][model]);
INI_Int("world", vInfo[playerid][world]);
INI_Int("interior", vInfo[playerid][interior]);
INI_Float("angle", vInfo[playerid][angle]);
INI_Float("pos:x", vInfo[playerid][x_]);
INI_Float("pos:y", vInfo[playerid][y_]);
INI_Float("pos:z", vInfo[playerid][z_]);
}
INI_ParseFile(FolderVehicles(playerid), "loadvehicle");
vInfo[playerid][vehicle] = 1;
}
else if(!fexist(FolderVehicles(playerid)))
{
vInfo[playerid][vehicle] = 0, vInfo[playerid][model] = 0, vInfo[playerid][world] = 0;
vInfo[playerid][x_] = 0.00, vInfo[playerid][y_] = 0.00, vInfo[playerid][z_] = 0.00;
}
return true;
}
public OnPlayerDisconnect(playerid, reason)
{
if(vInfo[playerid][vehicle] != 0)
{
new Float:pos[4];
GetVehicleZAngle(vInfo[playerid][vehicle], pos[3]);
GetVehiclePos(vInfo[playerid][vehicle], pos[0], pos[1], pos[2]);
PutPlayerInVehicle(playerid, vInfo[playerid][vehicle], 0);
new INI:File = INI_Open(FolderVehicles(playerid));
INI_SetTag(File, "Info vehicle");
INI_WriteInt(File, "model", vInfo[playerid][model]);
INI_WriteInt(File, "world", GetVehicleVirtualWorld(vInfo[playerid][vehicle]));
INI_WriteInt(File, "interior", GetPlayerInterior(playerid));
INI_WriteFloat(File, "angle", pos[3]);
INI_WriteFloat(File, "pos:x", pos[0]);
INI_WriteFloat(File, "pos:y", pos[1]);
INI_WriteFloat(File, "pos:z", pos[2]);
INI_Close(File);
//..
DestroyVehicle(vInfo[playerid][vehicle]);
}
return true;
}
public OnPlayerRequestSpawn(playerid)
{
if(vInfo[playerid][vehicle] != 0)
{
vInfo[playerid][vehicle] = CreateVehicle(vInfo[playerid][model], vInfo[playerid][x_], vInfo[playerid][y_], vInfo[playerid][z_], vInfo[playerid][angle], random(126), random(126), (60*60));
SetVehicleVirtualWorld(vInfo[playerid][vehicle], vInfo[playerid][world]);
LinkVehicleToInterior(vInfo[playerid][vehicle], vInfo[playerid][interior]);
}
return true;
}
FolderVehicles(playerid)
{
new string[80], name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "/vehicles/%s.ini", name);
return string;
}
CMD:cars(playerid, params[])
{
if(sscanf(params, "i", params[0]))
return SendClientMessage(playerid, -1, "usage: /cars [vehicle 1-7].");
if(vInfo[playerid][vehicle] != 0)
{
DestroyVehicle(vInfo[playerid][vehicle]);
}
//..
new Float:pos[4];
GetPlayerFacingAngle(playerid, pos[3]);
GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
//..
switch(params[0])
{
case 1:
{
if(GetPlayerMoney(playerid) < 1200000)
return SendClientMessage(playerid, -1, "You don't have enough cash to buy this car!");
vInfo[playerid][vehicle] = CreateVehicle(541, pos[0], pos[1], pos[2], pos[3], random(126), random(126), (60*60));
GivePlayerMoney(playerid, -1200000);
vInfo[playerid][model] = 541;
}
case 2:
{
if(GetPlayerMoney(playerid) < 1900000)
return SendClientMessage(playerid, -1, "You don't have enough cash to buy this car!");
vInfo[playerid][vehicle] = CreateVehicle(411, pos[0], pos[1], pos[2], pos[3], random(126), random(126), (60*60));
GivePlayerMoney(playerid, -1900000);
vInfo[playerid][model] = 411;
}
case 3:
{
if(GetPlayerMoney(playerid) < 4000000)
return SendClientMessage(playerid, -1, "You don't have enough cash to buy this car!");
vInfo[playerid][vehicle] = CreateVehicle(494, pos[0], pos[1], pos[2], pos[3], random(126), random(126), (60*60));
GivePlayerMoney(playerid, -4000000);
vInfo[playerid][model] = 494;
}
case 4:
{
if(GetPlayerMoney(playerid) < 22000)
return SendClientMessage(playerid, -1, "You don't have enough cash to buy this car!");
vInfo[playerid][vehicle] = CreateVehicle(409, pos[0], pos[1], pos[2], pos[3], random(126), random(126), (60*60));
GivePlayerMoney(playerid, -22000);
vInfo[playerid][model] = 409;
}
case 5:
{
if(GetPlayerMoney(playerid) < 460000)
return SendClientMessage(playerid, -1, "You don't have enough cash to buy this car!");
vInfo[playerid][vehicle] = CreateVehicle(560, pos[0], pos[1], pos[2], pos[3], random(126), random(126), (60*60));
GivePlayerMoney(playerid, -460000);
vInfo[playerid][model] = 560;
}
case 6:
{
if(GetPlayerMoney(playerid) < 600000)
return SendClientMessage(playerid, -1, "You don't have enough cash to buy this car!");
vInfo[playerid][vehicle] = CreateVehicle(506, pos[0], pos[1], pos[2], pos[3], random(126), random(126), (60*60));
GivePlayerMoney(playerid, -600000);
vInfo[playerid][model] = 506;
}
case 7:
{
if(GetPlayerMoney(playerid) < 5000000)
return SendClientMessage(playerid, -1, "You don't have enough cash to buy this car!");
vInfo[playerid][vehicle] = CreateVehicle(521, pos[0], pos[1], pos[2], pos[3], random(126), random(126), (60*60));
GivePlayerMoney(playerid, -5000000);
vInfo[playerid][model] = 521;
}
}
SetVehicleVirtualWorld(vInfo[playerid][vehicle], GetPlayerVirtualWorld(playerid));
LinkVehicleToInterior(vInfo[playerid][vehicle], GetPlayerInterior(playerid));
PutPlayerInVehicle(playerid, vInfo[playerid][vehicle], 0);
//..
return true;
}
#endif
[Info vehicle] model = 411 world = 0 interior = 0 angle = 0.000000 pos = 0.000000 pos:y = 0.000000 pos:z = 0.000000 |
vInfo[playerid][vehicle] = 0, vInfo[playerid][model] = 0, vInfo[playerid][world] = 0;
vInfo[playerid][x_] = 0.00, vInfo[playerid][y_] = 0.00, vInfo[playerid][z_] = 0.00;
vInfo[playerid][vehicle] =0, vInfo[playerid][model] =0, vInfo[playerid][world] =0;
vInfo[playerid][x_] =0.00, vInfo[playerid][y_] =0.00, vInfo[playerid][z_] =0.00;