save car +REP
#1

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 the car must load in cars.cfg
Reply
#2

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:vXFloat:vYFloat:vZFloat:vA;
   
GetVehiclePos(vidvXvYvZ);
   
GetVehicleZAngle(vidvA);
   
// 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.
Reply
#3

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:vXFloat:vYFloat:vZFloat:vA;
   
GetVehiclePos(vidvXvYvZ);
   
GetVehicleZAngle(vidvA);
   
// 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
Reply
#4

Sorry, can't help you with that.
Reply
#5

Just use INI_WriteFloat.
Reply
#6

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
{
getpos x y z
getangel a
ini_writefloat("X"x);
}
right?
Reply
#7

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
Reply
#8

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?
Reply
#9

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) ?
Reply
#10

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)