01.02.2013, 16:06
Hi,
I'm starting to create a RP script, but I'm stuck for months now with the vehicle system.
I want it to check what next file is available (for example: Vehicle_1 and 2 are used, it should go to Vehicle_3)
I tried to make a code for that:
But it doesn't work properly
My second problem,
I have added "CarID" to the vehicle files and when It spawns it sets the CarID in the file to the ID the car has IG (that all works fine).
When I wanna change my vehicle color it has to run through all the vehicle files and search in what file the CarID is the same as the VehicleID In game.
Code of the command
I am doing something wrong but I don't know what :S
Please help me out so I can continue scripting.
I'm starting to create a RP script, but I'm stuck for months now with the vehicle system.
I want it to check what next file is available (for example: Vehicle_1 and 2 are used, it should go to Vehicle_3)
I tried to make a code for that:
pawn Код:
stock GetFreeVehicleSlot()
{
for(new i = 0; i < MAX_VEHICLES; i++)
{
new string[1000];
format(string, sizeof(string), "Vehicles/Vehicle_%d.ini", i);
if(fexist(string)) return i+1;
}
return -1;
}
My second problem,
I have added "CarID" to the vehicle files and when It spawns it sets the CarID in the file to the ID the car has IG (that all works fine).
When I wanna change my vehicle color it has to run through all the vehicle files and search in what file the CarID is the same as the VehicleID In game.
Code of the command
pawn Код:
command(setcarcolor, playerid, params[])
{
new col1, col2;
if(sscanf(params, "dd", col1, col2))
{
if(Player[playerid][AdminLevel] >= 4)
{
SendClientMessage(playerid, WHITE, "SYNTAX: /setcarcolor [color1] [color2]");
}
}
else
{
if(Player[playerid][AdminLevel] >= 4)
{
if(IsPlayerInAnyVehicle(playerid))
{
for(new i = 0; i < MAX_VEHICLES; i++)
{
if(Vehicles[i][CarID] == GetPlayerVehicleID(playerid))
{
new string[128];
{
format(string, sizeof(string), "Vehicles/Vehicle_%d.ini", i);
}
if(fexist(string))
{
Vehicles[i][Col1] = col1;
Vehicles[i][Col2] = col2;
ChangeVehicleColor(i, col1, col2);
SaveExistingVehicle(i);
}
else
{
SendClientMessage(playerid, WHITE, "This is not a saved car!");
}
}
}
}
}
}
return 1;
}
Please help me out so I can continue scripting.