Save Vehicle Object Problem ( $$ )
#1

Hey guys ! I'm currently scripting a Command that create vehicle object and saves it in the player files. Problem is, Its the first time i'm doing a command that saves and i'd like a little help. ( I can pay if anyone want to help me in private )

Ok so here is how it goes :

-Player has to be a mechanic to use /cartoys

-When /cartoys is used, shows a dialog box that ask a choice between 3 car items

-When choosing car item number 1 ( because other arent scripted yet ) it checks if the player is in a car and as driver. Then if yes, a surf board is attached to the car.

The thing is, the surf respawns with the car but, doesnt save when server restarts

I tried to make it save, I'm stuck somewhere on my code and can't get what to write next.

Ok so here's the code

Код:
new cartoys[MAX_PLAYERS];
Код:
pCToyModel[3],
	Float:pCToyX[3],
	Float:pCToyY[3],
	Float:pCToyZ[3],
	Float:pCToyRX[3],
	Float:pCToyRY[3],
	Float:pCToyRZ[3],
 	Float:pCToySX[3],
    Float:pCToySY[3],
    Float:pCToySZ[3],
Код:
stock ClearChar(playerid)
    for(new i=0; i<3; i++) // Toys
    {
    	PlayerInfo[playerid][pCToyModel][i] = 0;
        PlayerInfo[playerid][pCToyX][i] = 0;
		PlayerInfo[playerid][pCToyY][i] = 0;
		PlayerInfo[playerid][pCToyZ][i] = 0;
		PlayerInfo[playerid][pCToyRX][i] = 0;
		PlayerInfo[playerid][pCToyRY][i] = 0;
		PlayerInfo[playerid][pCToyRZ][i] = 0;
	 	PlayerInfo[playerid][pCToySX][i] = 0;
	    PlayerInfo[playerid][pCToySY][i] = 0;
	    PlayerInfo[playerid][pCToySZ][i] = 0;
	return 1;
}
Код:
stock SaveChar(playerid)
			SaveCToys(playerid, file);

//its not the actual code but its too long. ( I can give it on demand tho)
Код:
stock LoadChar(playerid)
//same here its quite long	
LoadCToys(playerid, file);
The save Ctoys
Код:
stock SaveCToys(playerid, file[])
{
	// Toys Model
	dini_IntSet(file, "CtModel0", PlayerInfo[playerid][pCToyModel][0]);
	dini_IntSet(file, "CtModel1", PlayerInfo[playerid][pCToyModel][1]);
	dini_IntSet(file, "CtModel2", PlayerInfo[playerid][pCToyModel][2]);

	// Toys X
	dini_FloatSet(file, "CtX0", PlayerInfo[playerid][pCToyX][0]);	dini_FloatSet(file, "CtX1", PlayerInfo[playerid][pCToyX][1]);	dini_FloatSet(file, "CtX2", PlayerInfo[playerid][pCToyX][2]);
	// Toys Y
	dini_FloatSet(file, "CtY0", PlayerInfo[playerid][pCToyY][0]);	dini_FloatSet(file, "CtY1", PlayerInfo[playerid][pCToyY][1]);	dini_FloatSet(file, "CtY2", PlayerInfo[playerid][pCToyY][2]);
	
	// Toy Z
	dini_FloatSet(file, "CtZ0", PlayerInfo[playerid][pCToyZ][0]);	dini_FloatSet(file, "CtZ1", PlayerInfo[playerid][pCToyZ][1]);	dini_FloatSet(file, "CtZ2", PlayerInfo[playerid][pCToyZ][2]);
	
	// Toy RX
	dini_FloatSet(file, "CtRX0", PlayerInfo[playerid][pCToyRX][0]); dini_FloatSet(file, "CtRX1", PlayerInfo[playerid][pCToyRX][1]);	dini_FloatSet(file, "CtRX2", PlayerInfo[playerid][pCToyRX][2]);
	
	// Toy RY
	dini_FloatSet(file, "CtRY0", PlayerInfo[playerid][pCToyRY][0]); dini_FloatSet(file, "CtRY1", PlayerInfo[playerid][pCToyRY][1]);	dini_FloatSet(file, "CtRY2", PlayerInfo[playerid][pCToyRY][2]);

	// Toy RZ
	dini_FloatSet(file, "CtRZ0", PlayerInfo[playerid][pCToyRZ][0]); dini_FloatSet(file, "CtRZ1", PlayerInfo[playerid][pCToyRZ][1]);	dini_FloatSet(file, "CtRZ2", PlayerInfo[playerid][pCToyRZ][2]);

	// Toy SX
	dini_FloatSet(file, "CtSX0", PlayerInfo[playerid][pCToySX][0]); dini_FloatSet(file, "CtSX1", PlayerInfo[playerid][pCToySX][1]);	dini_FloatSet(file, "CtSX2", PlayerInfo[playerid][pCToySX][2]);

	// Toy SY
	dini_FloatSet(file, "CtSY0", PlayerInfo[playerid][pCToySY][0]); dini_FloatSet(file, "CtSY1", PlayerInfo[playerid][pCToySY][1]);	dini_FloatSet(file, "CtSY2", PlayerInfo[playerid][pCToySY][2]);

	// Toy SZ
	dini_FloatSet(file, "CtSZ0", PlayerInfo[playerid][pCToySZ][0]); dini_FloatSet(file, "CtSZ1", PlayerInfo[playerid][pCToySZ][1]);	dini_FloatSet(file, "CtSZ2", PlayerInfo[playerid][pCToySZ][2]);

	return 1;
}
The load Ctoys
Код:
stock LoadCToys(playerid, file[])
{
	// Toys
	PlayerInfo[playerid][pCToyModel][0] = dini_Int(file, "CtModel0");
	PlayerInfo[playerid][pCToyModel][1] = dini_Int(file, "CtModel1");
	PlayerInfo[playerid][pCToyModel][2] = dini_Int(file, "CtModel2");

	// Toys X
	PlayerInfo[playerid][pCToyX][0] = dini_Float(file, "CtX0"); PlayerInfo[playerid][pCToyX][1] = dini_Float(file, "CtX1");	PlayerInfo[playerid][pCToyX][2] = dini_Float(file, "CtX2");

	// Toys Y
	PlayerInfo[playerid][pCToyY][0] = dini_Float(file, "CtY0"); PlayerInfo[playerid][pCToyY][1] = dini_Float(file, "CtY1");	PlayerInfo[playerid][pCToyY][2] = dini_Float(file, "CtY2");

	// Toy Z
	PlayerInfo[playerid][pCToyZ][0] = dini_Float(file, "CtZ0"); PlayerInfo[playerid][pCToyZ][1] = dini_Float(file, "CtZ1");	PlayerInfo[playerid][pCToyZ][2] = dini_Float(file, "CtZ2");

	// Toy RX
	PlayerInfo[playerid][pCToyRX][0] = dini_Float(file, "CtRX0"); PlayerInfo[playerid][pCToyRX][1] = dini_Float(file, "CtRX1");	PlayerInfo[playerid][pCToyRX][2] = dini_Float(file, "CtRX2");

	// Toy RY
	PlayerInfo[playerid][pCToyRY][0] = dini_Float(file, "CtRY0");	PlayerInfo[playerid][pCToyRY][1] = dini_Float(file, "CtRY1");	PlayerInfo[playerid][pCToyRY][2] = dini_Float(file, "CtRY2");

	// Toy RZ
	PlayerInfo[playerid][pCToyRZ][0] = dini_Float(file, "CtRZ0");	PlayerInfo[playerid][pCToyRZ][1] = dini_Float(file, "CtRZ1");	PlayerInfo[playerid][pCToyRZ][2] = dini_Float(file, "CtRZ2");

	// Toy SX
	PlayerInfo[playerid][pCToySX][0] = dini_Float(file, "CtSX0");	PlayerInfo[playerid][pCToySX][1] = dini_Float(file, "CtSX1");	PlayerInfo[playerid][pCToySX][2] = dini_Float(file, "CtSX2");

	// Toy SY
	PlayerInfo[playerid][pCToySY][0] = dini_Float(file, "CtSY0");	PlayerInfo[playerid][pCToySY][1] = dini_Float(file, "CtSY1");	PlayerInfo[playerid][pCToySY][2] = dini_Float(file, "CtSY2");

	// Toy SZ
	PlayerInfo[playerid][pCToySZ][0] = dini_Float(file, "CtSZ0");	PlayerInfo[playerid][pCToySZ][1] = dini_Float(file, "CtSZ1");	PlayerInfo[playerid][pCToySZ][2] = dini_Float(file, "CtSZ2");

	for(new i=0; i<10; i++) // Toys
    {
	 	if(PlayerInfo[playerid][pCToySX][i] == 0) PlayerInfo[playerid][pCToySX][i] = 1;
	    if(PlayerInfo[playerid][pCToySY][i] == 0) PlayerInfo[playerid][pCToySY][i] = 1;
	    if(PlayerInfo[playerid][pCToySZ][i] == 0) PlayerInfo[playerid][pCToySZ][i] = 1;
    }
	return 1;
}
This is the case 0 ( case 1 and 2 arent scripted )
Код:
else if(dialogid == 111) // Car toys
	{
	    if(response)
	    {
	        switch(listitem)
	        {
	            case 0: // Surf Board
	            {
	                new vehicleid = GetPlayerVehicleID(playerid);
	                new string[128];
	                new Float:vH; GetVehicleHealth(GetPlayerVehicleID(playerid), vH);
					new Float:vel[3]; GetVehicleVelocity(GetPlayerVehicleID(playerid), vel[0], vel[1], vel[2]);
	                if(vH < 250) return SendClientMessage(playerid, COLOR_GREY, "The vehicle's engine is too hot to be modified.");
	                if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid, COLOR_GREY, "You must be in the driver seat to modify a vehicle.");
					if(vel[0] != 0 || vel[1] != 0 || vel[2] != 0) return SendClientMessage(playerid, COLOR_GREY, "You can't modify a vehicle while it's moving.");
     				GivePlayerMoney(playerid, -200);
					PlayerInfo[playerid][pJobSkill][JOB_MECHANIC] ++;
					PlayerPlaySound(playerid,1133,0.0,0.0,0.0);
					format(string, sizeof(string), "* %s is modifying the vehicle he's inside.", RPN(playerid));
					SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
					new surfboard = CreateObject(2404,0,0,0,0,0,0,0);
     				new playerveh = GetPlayerVehicleID(playerid);
     				AttachObjectToVehicle(surfboard, playerveh, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0);
					format(string, sizeof(string), "* %s has attached a surfboard on the car.", RPN(playerid));
					PlayerInfo[playerid][pCToyModel][index] = model; //my error must be in this line but i don't know how to use these lines.
	            }
So i think everything is here and i think that my error is just above. Like i said i'll be more than grateful to anyone who helps of course i rep but I can also pay. Thanks
Reply


Messages In This Thread
Save Vehicle Object Problem ( $$ ) - by Mikeydoo - 11.01.2016, 01:58
Re: Save Vehicle Object Problem ( $$ ) - by Black Axe - 11.01.2016, 02:34
Re: Save Vehicle Object Problem ( $$ ) - by Mikeydoo - 11.01.2016, 02:38
Re: Save Vehicle Object Problem ( $$ ) - by Mikeydoo - 11.01.2016, 03:01

Forum Jump:


Users browsing this thread: 1 Guest(s)