SA-MP Forums Archive
[HELP]Ingame Car Spawn & Save - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: [HELP]Ingame Car Spawn & Save (/showthread.php?tid=375410)



[HELP]Ingame Car Spawn & Save - Hyperfire - 06.09.2012

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.


Re: [HELP]Ingame Car Spawn & Save - Hyperfire - 08.09.2012

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.


Re: [HELP]Ingame Car Spawn & Save - Hyperfire - 11.09.2012

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.


Re: [HELP]Ingame Car Spawn & Save - lamarr007 - 11.09.2012

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().


Re: [HELP]Ingame Car Spawn & Save - Hyperfire - 11.09.2012

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.


Re: [HELP]Ingame Car Spawn & Save - lamarr007 - 11.09.2012

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


Re: [HELP]Ingame Car Spawn & Save - Hyperfire - 11.09.2012

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).


Re: [HELP]Ingame Car Spawn & Save - lamarr007 - 11.09.2012

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;
}



Re: [HELP]Ingame Car Spawn & Save - Hyperfire - 11.09.2012

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?


Re: [HELP]Ingame Car Spawn & Save - Hyperfire - 15.09.2012

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.