Quote:
Originally Posted by faeldk
Esqueзeu do leite :O!
|
affz, eu tenho o FS, so preciso disso de salvar e de como comprar:
Код:
/*
****************** CAR OWNERSHIP FILTERSCRIPT **********************************
*/
#include <a_samp>
#include <dini>
#define FILTERSCRIPT
new bool:validcar[MAX_VEHICLES];
stock GetFreeVehicleSlot()
{
for(new i = 0; i < sizeof(validcar); i ++)
{
if(!validcar[i]) return i;
}
return -1;
}
enum carDataEnum {
model,
Float:xspawn,
Float:yspawn,
Float:zspawn,
Float:anglespawn,
col1,
col2,
respawn,
owner[20]
}
new carData[MAX_VEHICLES][carDataEnum];
stock CreateVehicleEx(modelid, Float:x, Float:y, Float:z, Float:angle, color1, color2, respawntime, ownername[20])
{
new carid = GetFreeVehicleSlot();
carData[carid][model] = modelid;
carData[carid][xspawn] = x;
carData[carid][yspawn] = y;
carData[carid][zspawn] = z;
carData[carid][anglespawn] = angle;
carData[carid][col1] = color1;
carData[carid][col2] = color2;
carData[carid][respawn] = respawntime;
carData[carid][owner] = ownername;
validcar[carid] = true;
CreateVehicle(modelid, x, y, z, angle, color1, color2, respawntime);
return carid;
}
stock SaveVehicle(vehicle, filename[36])
{
new iniid = ini_CreateIniFile(filename);
ini_SetInt(iniid, "Model", carData[vehicle][model]);
ini_SetFloat(iniid, "XSpawn", carData[vehicle][xspawn]);
ini_CloseIni(iniid);
}
stock SaveAllVehicles()
{
new saveindex = 0;
new fname[36];
for(new i = 0; i < MAX_VEHICLES; i ++)
{
if(validcar[i])
{
format(fname, sizeof(fname), "fvehicles/%d.ini", saveindex); //You can also add a subfolder here<.
SaveVehicle(i, fname);
saveindex ++;
}
}
stock LoadVehicle(filename[36])
{
new iniid = ini_OpenIni(filename);
CreateVehicleEx(ini_GetInt(iniid, "Model"), ini_GetFloat(iniid, "XSpawn"), ...);
ini_CloseIni(iniid);
}
stock LoadAllVehicles()
{
new fname[36];
new index = 0;
format(fname, sizeof(fname), "%d.ini", index);
while(fexist(fname))
{
LoadVehicle(fname);
index ++;
format(fname, sizeof(fname), "%d.ini", index);
}
}
public OnFilterScriptInit()
{
printf("****************** CAR OWNERSHIP FILTERSCRIPT **********************************");
return 1;
}
public OnFilterScriptExit()
{
printf("****************** CAR OWNERSHIP FILTERSCRIPT **********************************");
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/buy, cmdtext, true, 10) == 0)
{
new id = GetPlayerVehicleID(playerid);
if(IsPlayerInAnyVehicle(playerid) && validcar[id] == true)
{
return 1;
}
return 0;
}