save car +REP -
peterory - 29.05.2012
mean that car spawn in ls but i drive it to lv then i exit the game and exit the gamemode
and open the gamemode again that car will be spawn in lv that mean I DRIVE IT TO THERE AND THEN HE IS THERE ALSO SPAWN
i wan't use y_ini
and
![Smiley](images/smilies/smile.png)
the car must load in cars.cfg
Re: save car +REP -
mati233 - 29.05.2012
I dont know how to store information or load it from files, so I'll just tell give you some tips.
You just need to get the position of the vehicle and save it on the file, you can get the position by adding for example onplayerupdate:
PHP код:
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER){
new vid=GetPlayerVehicleID(playerid);
new Float:vX, Float:vY, Float:vZ, Float:vA;
GetVehiclePos(vid, vX, vY, vZ);
GetVehicleZAngle(vid, vA);
// code to store the info on the file here
}
I dont know if you already have a file where you store the vehicle information, if you have, you can just make it update the coords, and when restart it will load the new ones automaticly, but if you don't explain better the situation and I hope I can help you.
Re: save car +REP -
peterory - 29.05.2012
Quote:
Originally Posted by mati233
I dont know how to store information or load it from files, so I'll just tell give you some tips.
You just need to get the position of the vehicle and save it on the file, you can get the position by adding for example onplayerupdate:
PHP код:
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER){
new vid=GetPlayerVehicleID(playerid);
new Float:vX, Float:vY, Float:vZ, Float:vA;
GetVehiclePos(vid, vX, vY, vZ);
GetVehicleZAngle(vid, vA);
// code to store the info on the file here
}
I dont know if you already have a file where you store the vehicle information, if you have, you can just make it update the coords, and when restart it will load the new ones automaticly, but if you don't explain better the situation and I hope I can help you.
|
i know how to get the pos and angle
i just wan't to store the code into the file
Re: save car +REP -
mati233 - 29.05.2012
Sorry, can't help you with that.
Re: save car +REP -
TzAkS. - 29.05.2012
Just use INI_WriteFloat.
Re: save car +REP -
peterory - 29.05.2012
Quote:
Originally Posted by TzAkS.
Just use INI_WriteFloat.
|
i wan't save all of my server's car
use
for(new i = 0; i <= 100
![Wink](images/smilies/wink.png)
{
getpos x y z
getangel a
ini_writefloat("X"x);
}
right?
Re: save car +REP -
SnG.Scot_MisCuDI - 29.05.2012
pawn Код:
new file[148];
new Float:X,Float:Y,Float:Z;
Saving
pawn Код:
format(file,sizeof(file),"Folder/cars.ini"); //replace Folder with the name of the folder in ScriptFiles
dini_FloatSet(file, "carX", X);
dini_FloatSet(file, "carY", Y);
dini_FloatSet(file, "carZ", Z);
Loading
pawn Код:
CreateVehicle(ID, dini_Float(String, "carX"),dini_Float(String, "carY"),dini_Float(String, "carZ").angle,color1,color2,respawn);
Im hoping you can do the rest: ID, Angle, Color1. Color2
I just showed you how to load/save
Re: save car +REP -
peterory - 29.05.2012
Quote:
Originally Posted by SnG.Scot_MisCuDI
pawn Код:
new file[148]; new Float:X,Float:Y,Float:Z;
Saving
pawn Код:
format(file,sizeof(file),"Folder/cars.ini"); //replace Folder with the name of the folder in ScriptFiles dini_FloatSet(file, "carX", X); dini_FloatSet(file, "carY", Y); dini_FloatSet(file, "carZ", Z);
Loading
pawn Код:
CreateVehicle(ID, dini_Float(String, "carX"),dini_Float(String, "carY"),dini_Float(String, "carZ").angle,color1,color2,respawn);
Im hoping you can do the rest: ID, Angle, Color1. Color2
I just showed you how to load/save
|
but i wan't save all of the server's car
just do that?
the server will load all car in one file?
Re: save car +REP -
peterory - 29.05.2012
Quote:
Originally Posted by n00b_scripter
make a loop for all cars and server will load all cars from one file
|
how to do that?
for(i = 0 to maxcar) ?
Re: save car +REP -
RoboN1X - 29.05.2012
Quote:
Originally Posted by peterory
how to do that?
for(i = 0 to maxcar) ?
|
pawn Код:
for new(i = 0; i <= MAX_VEHICLES; i++)
{
if(i != INVALID_VEHICLE_ID)
{
// your code here
}
}
Note: you may remove or change:
pawn Код:
if(i != INVALID_VEHICLE_ID)
if you want to use it on load code