[HELP]Ingame Car Spawn & Save
#1

Hey guys. Over the last few days I created a ingame car spawner which uses dialogs to spawn the cars and sets their spawning colors, now I want to be able to save the cars once I "Park" it with a command or when I get out of the car.

Now I know there are many people that already posted ways to do this, but since I am new to pawno I would like if someone could explain what code to use and what the code does(Something like a tutorial).

I'm using y_ini to store data, I know how to use y_ini to save and load info, but I'm not sure how to create a file for every car I spawn since its not the same as Getting a player name.

I would really appreciate it if someone could give me some info on how to create separate files for the cars and maybe(optional) a way to delete the files when I delete the car(With a command?).

Thanx in advance.

PS. I'm also willing to share what I have done so far, but I bet there are way better "Ingame Car Spawners" out there.
Reply
#2

Bump, come on guys, please, I know it can be done, I just want to learn how. Ive seen somewhere that you use a loop, but I don't know how to use loops nor do I know how they work.

I would really appreciate any help.

I want to make my ingame car spawner better.

Thanx in advance.
Reply
#3

Hi guys, please help me with this one. I want to use a loop or something to make a unique file for every car I want to save after I spawned it, like for example, I spawn a Bullet, drive it around a bit and find a place I want to "Park" it, I type /carsave or /park or something and the car saves in its own file called 0.ini or something which then contains the car's information like its model, position, angle and colors(I'm using y_ini). When I restart or exit the server and start the server back up the cars would automatically spawn where i Parked it.

Can someone help me to accomplish this? All I need is an example of what code to use and what that code is used for and why it is used, so I can sharpen my knowledge.

Thanx in advance.
Reply
#4

Just get all data of vehicle (position, angle, model and colors (https://sampforum.blast.hk/showthread.php?tid=235398)) and save it to playerґs account file
Then create vehicle with loaded data at OnPlayerConnect().
Reply
#5

The thing is that I want to spawn multiple cars for other players to use, without the need to copy and paste code into my gamemode/filterscript, hope you understand what I need.
Reply
#6

You want to save all vehicles on server? Or only player private vehicle, which player spawned (bought)?
Reply
#7

I want to spawn vehicles ingame, save them so I dont have to put "CreateStaticVehicleEx" in my game mode. So I would say "I want to save all vehicles on server", but only when I choose to and one at a time(With a command).
Reply
#8

pawn Код:
CMD:saveallvehicles(playerid, params[])
{
    if(pInfo[playerid][Admin] < 5) return SendClientMessage(playerid, color_red, "This command can use only admins!"); //I suppose you have custom admin system
    new Float:VX, Float:VY, Float:VZ, Float:VA, Float:VH, filestring[32];
    for(new i; i < MAX_VEHICLES; i++)
    {
        GetVehiclePos(i, VX, VY, VZ);
        GetVehicleZAngle(i, VA);
        GetVehicleHealth(i, VH);
        format(filestring, sizeof(filestring), "/data/vehicle/%i.ini", i); //Generated ini file name
        //Save this... I donґt work with Y_INI, you must complete this yourself
    }
    return 1;
}

public OnGameModeInit()
{
    new Float:VX, Float:VY, Float:VZ, Float:VA, Float:VH, VM, veh, filestring[32];
    for(new i; i < MAX_VEHICLES; i++)
    {
        format(filestring, sizeof(filestring), "/data/vehicle/%i.ini", i); //Generated ini file name
        //Load data from file
        veh = CreateVehicle(VM, VX, VY, VZ, VA, -1, -1, 10000);
        SetVehicleHealth(veh, VH);
    }
    return 1;
}
Reply
#9

Thanx for the response, trying it now, thanx for the comments also.

Oh and is there a way I can save only one car at a time? Like when I sit in a car and want to save that car only?
Reply
#10

Please, I would really like to know how this works, I have a car spawner and want to incorporate a save system so i can save the cars I want to stay in the server until I remove them.

Would appreciate it if someone could give me advice on how to do it with y_ini.

Thanx in advance.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)