CMD:cars(playerid, params[])
{
if(sscanf(params, "i", params[0]))
return SendClientMessage(playerid, -1, "usage: /cars [id 1-7].");
switch(params[0])
{
case 1:
{
if(GetPlayerMoney(playerid) < 1200000)
return SendClientMessage(playerid, 0, "You don't have enough cash to buy this car!");
GivePlayerMoney(playerid, -1200000);
new Float:p[4];
GetPlayerPos(playerid, p[0], p[1], p[2]);
GetPlayerFacingAngle(playerid, p[3]);
CreateVehicle(541, p[0], p[1], p[2], p[3]+90, -1, -1, 9999999);
}
case 2:
{
if(GetPlayerMoney(playerid) < 1900000)
return SendClientMessage(playerid, 0, "You don't have enough cash to buy this car!");
GivePlayerMoney(playerid, -1900000);
new Float:p[4];
GetPlayerPos(playerid, p[0], p[1], p[2]);
GetPlayerFacingAngle(playerid, p[3]);
CreateVehicle(411, p[0], p[1], p[2], p[3]+90, -1, -1, 9999999);
}
case 3:
{
if(GetPlayerMoney(playerid) < 4000000)
return SendClientMessage(playerid, 0, "You don't have enough cash to buy this car!");
GivePlayerMoney(playerid, -4000000);
new Float:p[4];
GetPlayerPos(playerid, p[0], p[1], p[2]);
GetPlayerFacingAngle(playerid, p[3]);
CreateVehicle(494, p[0], p[1], p[2], p[3]+90, -1, -1, 9999999);
}
case 4:
{
if(GetPlayerMoney(playerid) < 22000)
return SendClientMessage(playerid, 0, "You don't have enough cash to buy this car!");
GivePlayerMoney(playerid, -22000);
new Float:p[4];
GetPlayerPos(playerid, p[0], p[1], p[2]);
GetPlayerFacingAngle(playerid, p[3]);
CreateVehicle(409, p[0], p[1], p[2], p[3]+90, -1, -1, 9999999);
}
case 5:
{
if(GetPlayerMoney(playerid) < 460000)
return SendClientMessage(playerid, 0, "You don't have enough cash to buy this car!");
GivePlayerMoney(playerid, -460000);
new Float:p[4];
GetPlayerPos(playerid, p[0], p[1], p[2]);
GetPlayerFacingAngle(playerid, p[3]);
CreateVehicle(560, p[0], p[1], p[2], p[3]+90, -1, -1, 9999999);
}
case 6:
{
if(GetPlayerMoney(playerid) < 600000)
return SendClientMessage(playerid, 0, "You don't have enough cash to buy this car!");
GivePlayerMoney(playerid, -600000);
new Float:p[4];
GetPlayerPos(playerid, p[0], p[1], p[2]);
GetPlayerFacingAngle(playerid, p[3]);
CreateVehicle(506, p[0], p[1], p[2], p[3]+90, -1, -1, 9999999);
}
case 7:
{
if(GetPlayerMoney(playerid) < 5000000)
return SendClientMessage(playerid, 0, "You don't have enough cash to buy this car!");
GivePlayerMoney(playerid, -5000000);
new Float:p[4];
GetPlayerPos(playerid, p[0], p[1], p[2]);
GetPlayerFacingAngle(playerid, p[3]);
CreateVehicle(521, p[0], p[1], p[2], p[3]+90, -1, -1, 9999999);
}
}
return true;
}
#define CarPath "Cars/%s.ini"
enum PlayercInfo
{
PlayerName[20],
Car1Model,
Float:CarX1,
Float:CarY1,
Float:CarZ1,
Float:CarA1,
Car2Model,
Float:CarX2,
Float:CarY2,
Float:CarZ2,
Float:CarA2,
Car3Model,
Float:CarX3,
Float:CarY3,
Float:CarZ3,
Float:CarA3,
}
new cInfo[MAX_PLAYERS][PlayercInfo];
stock Path(playerid) //Will create a new stock so we can easily use it later to load/save user's data in user's path
{
new str[128],name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
format(str,sizeof(str),CarPath,name);
return str;
}
https://sampforum.blast.hk/showthread.php?tid=175565
You could at least attempt to do it before asking for help... you haven't even 'tried' to save it with y_ini. You can either: 1. Stop being so lazy and learn how to script for yourself. 2. Go to a script request thread. |
D:\da\filterscripts\Copy (3) of car.pwn(158) : warning 203: symbol is never used: "LoadVehicles"
D:\da\filterscripts\Copy (3) of car.pwn(158) : warning 203: symbol is never used: "SaveVehicles"
SaveVehicles()
{
new filestring[125];
new File: vfile = fopen("vehicles.txt", io_write);
for(new vehicleid = 1;vehicleid<MAX_VEH;vehicleid++)
{
if(cInfo[vehicleid][Car1Model] != 0)
{
format(filestring, sizeof(filestring), "%i,%f\n", // ... continue
cInfo[vehicleid][Car1Model],
cInfo[vehicleid][CarX1] // float
);
fwrite(vfile, filestring);
}
}
fclose(vfile);
}
LoadVehicles()
{
if(fexist("vehicles.txt"))
{
new string[125];
new SplitDiv[40][32];
new filestring[275];
new File: file = fopen(VEHICLE_FILE_, io_read);
if (file)
{
for(new vehicleid = 1;vehicleid<MAX_VEH;vehicleid++)
{
fread(file, filestring);
split(filestring, SplitDiv, ',');
cInfo[vehicleid][Car1Model] = strval(SplitDiv[0]);
cInfo[vehicleid][CarX1] = floatstr(SplitDiv[1]);
}
}
fclose(file);
}
}
This is warning not error you never used load and save vehicles,if you use them somewhere in script you won't get warnings anymore
|
D:\da\filterscripts\Copy (3) of car.pwn(158) : warning 203: symbol is never used: "LoadVehicles" D:\da\filterscripts\Copy (3) of car.pwn(158) : warning 203: symbol is never used: "SaveVehicles"
public OnPlayerConnect(playerid)
{
SaveVehicles()
{
new filestring[125];
new File: vfile = fopen("vehicles.txt", io_write);
for(new vehicleid = 1;vehicleid<MAX_VEH;vehicleid++)
{
if(cInfo[vehicleid][Car1Model] != 0)
{
format(filestring, sizeof(filestring), "%i,%f\n", // ... continue
cInfo[vehicleid][Car1Model],
cInfo[vehicleid][CarX1] // float
);
fwrite(vfile, filestring);
}
}
fclose(vfile);
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
LoadVehicles()
{
if(fexist("vehicles.txt"))
{
new string[125];
new SplitDiv[40][32];
new filestring[275];
new File: file = fopen(VEHICLE_FILE_, io_read);
if (file)
{
for(new vehicleid = 1;vehicleid<MAX_VEH;vehicleid++)
{
fread(file, filestring);
split(filestring, SplitDiv, ',');
cInfo[vehicleid][Car1Model] = strval(SplitDiv[0]);
cInfo[vehicleid][CarX1] = floatstr(SplitDiv[1]);
}
}
fclose(file);
return 1;
}
public OnPlayerConnect(playerid) { LoadVehicles(); return 1; } public OnPlayerDisconnect(playerid, reason) { SaveVehicles(); return 1; } SaveVehicles() { new filestring[125]; new File: vfile = fopen("vehicles.txt", io_write); for(new vehicleid = 1;vehicleid<MAX_VEH;vehicleid++) { if(cInfo[vehicleid][Car1Model] != 0) { format(filestring, sizeof(filestring), "%i,%f\n", // ... continue cInfo[vehicleid][Car1Model], cInfo[vehicleid][CarX1] // float ); fwrite(vfile, filestring); } } fclose(vfile); return 1; } LoadVehicles() { if(fexist("vehicles.txt")) { new string[125]; new SplitDiv[40][32]; new filestring[275]; new File: file = fopen(VEHICLE_FILE_, io_read); if (file) { for(new vehicleid = 1;vehicleid<MAX_VEH;vehicleid++) { fread(file, filestring); split(filestring, SplitDiv, ','); cInfo[vehicleid][Car1Model] = strval(SplitDiv[0]); cInfo[vehicleid][CarX1] = floatstr(SplitDiv[1]); } } fclose(file); return 1; }