Heelp with my script
#1

Hello i would really like to have some help with my vehicle system


iam using Mysql and strcmp


and the thing is when i buy a car "Ingame" it say you bought a vehicle the vehicle is registrated to You.

And the car is my untill i Close down the server or somthing then when i start server again the car is gone and it says when i try to spawn it where i parked it before it say you dont have a car in this slot and i have to buy a new one... :/ how do i make the car save? i have a Table for it on mysql but it just says this on the table when i buy a car 0.0.0.0.0.0.0.0.0 in all Squares. but in some squares is say Owner Example (Tim_Ohlsson) but thats old cars from when i downloaded the GM and when i try to remove all cars and stuff i get errors in GM so i dont now why they wont save please help!!!
Reply
#2

I've had this issue before, the GMX/Restart causes all the variables in my script to reset, I can't remember how I fixed it though (PVars don't apply to this scenario I believe).
Reply
#3

Well then the variable system seems to be working since the car is yours. However, in some way it fails to save the vehicle when you disconnect. Can you please show us the lines where you save and load the vehicles? Otherwise it's kind of hard for us to help.
Reply
#4

Maybe this one?

Код:
new car = VehicleOwned[vehicleid];
	if(CarInfo[car][cMod][0] == 0)
	{
	    CarInfo[car][cMod][0] = componentid;
	    SendClientMessage(playerid,COLOR_WHITE,"Vehicle component bought for 100$, Slot 0.");
	    GivePlayerPCash(playerid,-100);
	    //SaveCars();
	}
    else if(CarInfo[car][cMod][1] == 0)
	{
	    CarInfo[car][cMod][1] = componentid;
	    SendClientMessage(playerid,COLOR_WHITE,"Vehicle component bought for 100$, Slot 1.");
	    GivePlayerPCash(playerid,-100);
	    //SaveCars();
	}
	else if(CarInfo[car][cMod][2] == 0)
	{
	    CarInfo[car][cMod][2] = componentid;
	    SendClientMessage(playerid,COLOR_WHITE,"Vehicle component bought for 100$, Slot 2.");
	    GivePlayerPCash(playerid,-100);
	    //SaveCars();
	}
	else if(CarInfo[car][cMod][3] == 0)
	{
	    CarInfo[car][cMod][3] = componentid;
	    SendClientMessage(playerid,COLOR_WHITE,"Vehicle component bought for 100$, Slot 3.");
	    GivePlayerPCash(playerid,-100);
	    //SaveCars();
	}
	else if(CarInfo[car][cMod][4] == 0)
	{
	    CarInfo[car][cMod][4] = componentid;
	    SendClientMessage(playerid,COLOR_WHITE,"Vehicle component bought for 100$, Slot 4.");
	    GivePlayerPCash(playerid,-100);
	    //SaveCars();
	}
	else if(CarInfo[car][cMod][5] == 0)
	{
	    CarInfo[car][cMod][5] = componentid;
	    SendClientMessage(playerid,COLOR_WHITE,"Vehicle component bought for 100$, Slot 5.");
	    GivePlayerPCash(playerid,-100);
	    //SaveCars();
	}
    else if(CarInfo[car][cMod][6] == 0)
	{
	    CarInfo[car][cMod][6] = componentid;
	    SendClientMessage(playerid,COLOR_WHITE,"Vehicle component bought for 100$, Slot 6.");
	    GivePlayerPCash(playerid,-100);
	    //SaveCars();
	}
	else if(CarInfo[car][cMod][7] == 0)
	{
	    CarInfo[car][cMod][7] = componentid;
	    SendClientMessage(playerid,COLOR_WHITE,"Vehicle component bought for 100$, Slot 7.");
	    GivePlayerPCash(playerid,-100);
	    //SaveCars();
	}
	else if(CarInfo[car][cMod][8] == 0)
	{
	    CarInfo[car][cMod][8] = componentid;
	    SendClientMessage(playerid,COLOR_WHITE,"Vehicle component bought for 100$, Slot 8.");
	    GivePlayerPCash(playerid,-100);
	    //SaveCars();
	}
	else
	{
	    SendClientMessage(playerid,COLOR_WHITE,"You vehicle components has hit its limited, Please /v unmod or exit.");
	}
	return 1;
}
Код:
forward Restarting();
public Restarting()
{
	new string[128];
	new Restart = 20;
	SaveCars();
	OnPropUpdate();
	foreach (Player, i)
	{
		if(Restart >= 1)
		{
	    	Restart --;
	    	PlayerPlaySound(i, 1138, 0.0, 0.0, 0.0);
	    	format(string, sizeof(string), "~n~~r~%d",Restart);
			GameTextForAll(string, 5000, 3);
		}
		else if(Restart == 0)
		{
			OnPlayerDataSave(i);
	    	SendRconCommand("gmx");
		}
	}
	return 1;
}
Код:
/*forward SaveCars();
public SaveCars()
{
    new idx;
	new File: file2;
	while (idx < sizeof(CarInfo))
	{
		new coordsstring[256];
		format(coordsstring, sizeof(coordsstring), "%d,%f,%f,%f,%f,%d,%d,%s,%s,%d,%s,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%i,%i,%i,%i,%i,%i,%i,%i,%f,%i,%d,%i,%i,%i,%i\n",
		CarInfo[idx][cModel],
		CarInfo[idx][cLocationx],
		CarInfo[idx][cLocationy],
		CarInfo[idx][cLocationz],
		CarInfo[idx][cAngle],
		CarInfo[idx][cColorOne],
		CarInfo[idx][cColorTwo],
		CarInfo[idx][cOwner],
		CarInfo[idx][cDescription],
		CarInfo[idx][cValue],
		CarInfo[idx][cLicense],
		CarInfo[idx][cOwned],
		CarInfo[idx][cLock],
		CarInfo[idx][cMod][0],
		CarInfo[idx][cMod][1],
		CarInfo[idx][cMod][2],
		CarInfo[idx][cMod][3],
		CarInfo[idx][cMod][4],
		CarInfo[idx][cMod][5],
		CarInfo[idx][cMod][6],
		CarInfo[idx][cMod][7],
		CarInfo[idx][cMod][8],
		CarInfo[idx][cMod][9],
		CarInfo[idx][cDonate],
		CarInfo[idx][cFuel],
		CarInfo[idx][cTrunkWep][1],
		CarInfo[idx][cTrunkAmmo][1],
		CarInfo[idx][cTrunkWep][2],
		CarInfo[idx][cTrunkAmmo][2],
		CarInfo[idx][cTrunkWep][3],
		CarInfo[idx][cTrunkAmmo][3],
		CarInfo[idx][cTrunkWep][4],
		CarInfo[idx][cTrunkAmmo][4],
		CarInfo[idx][cTrunkArmour],
		CarInfo[idx][cTrunkCounter],
		CarInfo[idx][cAlarm],
		CarInfo[idx][cTrunkDrugs],
		CarInfo[idx][cTrunkMats],
		CarInfo[idx][cImpounded],
		CarInfo[idx][cImpoundedPrice]);
		if(idx == 0)
		{
			file2 = fopen("cars.cfg", io_write);
		}
		else
		{
			file2 = fopen("cars.cfg", io_append);
		}
		fwrite(file2, coordsstring);
		idx++;
		fclose(file2);
	}
}*/

forward SaveCars();
public SaveCars()
{
    new idx;
	new string[1024];
	while (idx < sizeof(CarInfo))
	{
		format(string, sizeof(string), "UPDATE `cars` SET `Model`=%d,`LocationX`=%f,`LocationY`=%f,`LocationZ`=%f,`Angle`=%f,`Color1`=%d,`Color2`=%d,`Owner`='%s',`Description`='%s',`Value`=%d,`License`='%s',`Owned`=%d,`Lock`=%d,`Mod0`=%d,`Mod1`=%d,`Mod2`=%d,`Mod3`=%d,`Mod4`=%d,`Mod5`=%d,`Mod6`=%d,`Mod7`=%d,`Mod8`=%d,`Mod9`=%d,`Donate`=%d,`Fuel`=%d,`TrunkWeapon1`=%i,`TrunkAmmo1`=%i,`TrunkWeapon2`=%i,`TrunkAmmo2`=%i,`TrunkWeapon3`=%i,`TrunkAmmo3`=%i WHERE `ID`=%d",
		CarInfo[idx][cModel],
		CarInfo[idx][cLocationx],
		CarInfo[idx][cLocationy],
		CarInfo[idx][cLocationz],
		CarInfo[idx][cAngle],
		CarInfo[idx][cColorOne],
		CarInfo[idx][cColorTwo],
		CarInfo[idx][cOwner],
		CarInfo[idx][cDescription],
		CarInfo[idx][cValue],
		CarInfo[idx][cLicense],
		CarInfo[idx][cOwned],
		CarInfo[idx][cLock],
		CarInfo[idx][cMod][0],
		CarInfo[idx][cMod][1],
		CarInfo[idx][cMod][2],
		CarInfo[idx][cMod][3],
		CarInfo[idx][cMod][4],
		CarInfo[idx][cMod][5],
		CarInfo[idx][cMod][6],
		CarInfo[idx][cMod][7],
		CarInfo[idx][cMod][8],
		CarInfo[idx][cMod][9],
		CarInfo[idx][cDonate],
		CarInfo[idx][cFuel],
		CarInfo[idx][cTrunkWep][1],
		CarInfo[idx][cTrunkAmmo][1],
		CarInfo[idx][cTrunkWep][2],
		CarInfo[idx][cTrunkAmmo][2],
		CarInfo[idx][cTrunkWep][3],
		CarInfo[idx][cTrunkAmmo][3],
		idx);
		mysql_query_ex(string);
		format(string, sizeof(string), "UPDATE `cars` SET `TrunkWeapon4`=%i,`TrunkAmmo4`=%i,`TrunkArmour`=%f,`TrunkCounter`=%i,`Alarm`=%d,`TrunkDrugs`=%i,`TrunkMats`=%i,`Impounded`=%i,`ImpoundedPrice`=%i, `Insurance`=%d WHERE `ID`=%d",
		CarInfo[idx][cTrunkWep][4],
		CarInfo[idx][cTrunkAmmo][4],
		CarInfo[idx][cTrunkArmour],
		CarInfo[idx][cTrunkCounter],
		CarInfo[idx][cAlarm],
		CarInfo[idx][cTrunkDrugs],
		CarInfo[idx][cTrunkMats],
		CarInfo[idx][cImpounded],
		CarInfo[idx][cImpoundedPrice],
		CarInfo[idx][cInsurance],
		idx);
		mysql_query_ex(string);
		idx++;
	}
}
Reply
#5

Quote:
Originally Posted by showarn
Посмотреть сообщение
Maybe this one?

Код:
new car = VehicleOwned[vehicleid];
	if(CarInfo[car][cMod][0] == 0)
	{
	    CarInfo[car][cMod][0] = componentid;
	    SendClientMessage(playerid,COLOR_WHITE,"Vehicle component bought for 100$, Slot 0.");
	    GivePlayerPCash(playerid,-100);
	    //SaveCars();
	}
    else if(CarInfo[car][cMod][1] == 0)
	{
	    CarInfo[car][cMod][1] = componentid;
	    SendClientMessage(playerid,COLOR_WHITE,"Vehicle component bought for 100$, Slot 1.");
	    GivePlayerPCash(playerid,-100);
	    //SaveCars();
	}
	else if(CarInfo[car][cMod][2] == 0)
	{
	    CarInfo[car][cMod][2] = componentid;
	    SendClientMessage(playerid,COLOR_WHITE,"Vehicle component bought for 100$, Slot 2.");
	    GivePlayerPCash(playerid,-100);
	    //SaveCars();
	}
	else if(CarInfo[car][cMod][3] == 0)
	{
	    CarInfo[car][cMod][3] = componentid;
	    SendClientMessage(playerid,COLOR_WHITE,"Vehicle component bought for 100$, Slot 3.");
	    GivePlayerPCash(playerid,-100);
	    //SaveCars();
	}
	else if(CarInfo[car][cMod][4] == 0)
	{
	    CarInfo[car][cMod][4] = componentid;
	    SendClientMessage(playerid,COLOR_WHITE,"Vehicle component bought for 100$, Slot 4.");
	    GivePlayerPCash(playerid,-100);
	    //SaveCars();
	}
	else if(CarInfo[car][cMod][5] == 0)
	{
	    CarInfo[car][cMod][5] = componentid;
	    SendClientMessage(playerid,COLOR_WHITE,"Vehicle component bought for 100$, Slot 5.");
	    GivePlayerPCash(playerid,-100);
	    //SaveCars();
	}
    else if(CarInfo[car][cMod][6] == 0)
	{
	    CarInfo[car][cMod][6] = componentid;
	    SendClientMessage(playerid,COLOR_WHITE,"Vehicle component bought for 100$, Slot 6.");
	    GivePlayerPCash(playerid,-100);
	    //SaveCars();
	}
	else if(CarInfo[car][cMod][7] == 0)
	{
	    CarInfo[car][cMod][7] = componentid;
	    SendClientMessage(playerid,COLOR_WHITE,"Vehicle component bought for 100$, Slot 7.");
	    GivePlayerPCash(playerid,-100);
	    //SaveCars();
	}
	else if(CarInfo[car][cMod][8] == 0)
	{
	    CarInfo[car][cMod][8] = componentid;
	    SendClientMessage(playerid,COLOR_WHITE,"Vehicle component bought for 100$, Slot 8.");
	    GivePlayerPCash(playerid,-100);
	    //SaveCars();
	}
	else
	{
	    SendClientMessage(playerid,COLOR_WHITE,"You vehicle components has hit its limited, Please /v unmod or exit.");
	}
	return 1;
}
Код:
forward Restarting();
public Restarting()
{
	new string[128];
	new Restart = 20;
	SaveCars();
	OnPropUpdate();
	foreach (Player, i)
	{
		if(Restart >= 1)
		{
	    	Restart --;
	    	PlayerPlaySound(i, 1138, 0.0, 0.0, 0.0);
	    	format(string, sizeof(string), "~n~~r~%d",Restart);
			GameTextForAll(string, 5000, 3);
		}
		else if(Restart == 0)
		{
			OnPlayerDataSave(i);
	    	SendRconCommand("gmx");
		}
	}
	return 1;
}
Код:
/*forward SaveCars();
public SaveCars()
{
    new idx;
	new File: file2;
	while (idx < sizeof(CarInfo))
	{
		new coordsstring[256];
		format(coordsstring, sizeof(coordsstring), "%d,%f,%f,%f,%f,%d,%d,%s,%s,%d,%s,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%i,%i,%i,%i,%i,%i,%i,%i,%f,%i,%d,%i,%i,%i,%i\n",
		CarInfo[idx][cModel],
		CarInfo[idx][cLocationx],
		CarInfo[idx][cLocationy],
		CarInfo[idx][cLocationz],
		CarInfo[idx][cAngle],
		CarInfo[idx][cColorOne],
		CarInfo[idx][cColorTwo],
		CarInfo[idx][cOwner],
		CarInfo[idx][cDescription],
		CarInfo[idx][cValue],
		CarInfo[idx][cLicense],
		CarInfo[idx][cOwned],
		CarInfo[idx][cLock],
		CarInfo[idx][cMod][0],
		CarInfo[idx][cMod][1],
		CarInfo[idx][cMod][2],
		CarInfo[idx][cMod][3],
		CarInfo[idx][cMod][4],
		CarInfo[idx][cMod][5],
		CarInfo[idx][cMod][6],
		CarInfo[idx][cMod][7],
		CarInfo[idx][cMod][8],
		CarInfo[idx][cMod][9],
		CarInfo[idx][cDonate],
		CarInfo[idx][cFuel],
		CarInfo[idx][cTrunkWep][1],
		CarInfo[idx][cTrunkAmmo][1],
		CarInfo[idx][cTrunkWep][2],
		CarInfo[idx][cTrunkAmmo][2],
		CarInfo[idx][cTrunkWep][3],
		CarInfo[idx][cTrunkAmmo][3],
		CarInfo[idx][cTrunkWep][4],
		CarInfo[idx][cTrunkAmmo][4],
		CarInfo[idx][cTrunkArmour],
		CarInfo[idx][cTrunkCounter],
		CarInfo[idx][cAlarm],
		CarInfo[idx][cTrunkDrugs],
		CarInfo[idx][cTrunkMats],
		CarInfo[idx][cImpounded],
		CarInfo[idx][cImpoundedPrice]);
		if(idx == 0)
		{
			file2 = fopen("cars.cfg", io_write);
		}
		else
		{
			file2 = fopen("cars.cfg", io_append);
		}
		fwrite(file2, coordsstring);
		idx++;
		fclose(file2);
	}
}*/

forward SaveCars();
public SaveCars()
{
    new idx;
	new string[1024];
	while (idx < sizeof(CarInfo))
	{
		format(string, sizeof(string), "UPDATE `cars` SET `Model`=%d,`LocationX`=%f,`LocationY`=%f,`LocationZ`=%f,`Angle`=%f,`Color1`=%d,`Color2`=%d,`Owner`='%s',`Description`='%s',`Value`=%d,`License`='%s',`Owned`=%d,`Lock`=%d,`Mod0`=%d,`Mod1`=%d,`Mod2`=%d,`Mod3`=%d,`Mod4`=%d,`Mod5`=%d,`Mod6`=%d,`Mod7`=%d,`Mod8`=%d,`Mod9`=%d,`Donate`=%d,`Fuel`=%d,`TrunkWeapon1`=%i,`TrunkAmmo1`=%i,`TrunkWeapon2`=%i,`TrunkAmmo2`=%i,`TrunkWeapon3`=%i,`TrunkAmmo3`=%i WHERE `ID`=%d",
		CarInfo[idx][cModel],
		CarInfo[idx][cLocationx],
		CarInfo[idx][cLocationy],
		CarInfo[idx][cLocationz],
		CarInfo[idx][cAngle],
		CarInfo[idx][cColorOne],
		CarInfo[idx][cColorTwo],
		CarInfo[idx][cOwner],
		CarInfo[idx][cDescription],
		CarInfo[idx][cValue],
		CarInfo[idx][cLicense],
		CarInfo[idx][cOwned],
		CarInfo[idx][cLock],
		CarInfo[idx][cMod][0],
		CarInfo[idx][cMod][1],
		CarInfo[idx][cMod][2],
		CarInfo[idx][cMod][3],
		CarInfo[idx][cMod][4],
		CarInfo[idx][cMod][5],
		CarInfo[idx][cMod][6],
		CarInfo[idx][cMod][7],
		CarInfo[idx][cMod][8],
		CarInfo[idx][cMod][9],
		CarInfo[idx][cDonate],
		CarInfo[idx][cFuel],
		CarInfo[idx][cTrunkWep][1],
		CarInfo[idx][cTrunkAmmo][1],
		CarInfo[idx][cTrunkWep][2],
		CarInfo[idx][cTrunkAmmo][2],
		CarInfo[idx][cTrunkWep][3],
		CarInfo[idx][cTrunkAmmo][3],
		idx);
		mysql_query_ex(string);
		format(string, sizeof(string), "UPDATE `cars` SET `TrunkWeapon4`=%i,`TrunkAmmo4`=%i,`TrunkArmour`=%f,`TrunkCounter`=%i,`Alarm`=%d,`TrunkDrugs`=%i,`TrunkMats`=%i,`Impounded`=%i,`ImpoundedPrice`=%i, `Insurance`=%d WHERE `ID`=%d",
		CarInfo[idx][cTrunkWep][4],
		CarInfo[idx][cTrunkAmmo][4],
		CarInfo[idx][cTrunkArmour],
		CarInfo[idx][cTrunkCounter],
		CarInfo[idx][cAlarm],
		CarInfo[idx][cTrunkDrugs],
		CarInfo[idx][cTrunkMats],
		CarInfo[idx][cImpounded],
		CarInfo[idx][cImpoundedPrice],
		CarInfo[idx][cInsurance],
		idx);
		mysql_query_ex(string);
		idx++;
	}
}
Uncomment SaveCars();
Reply
#6

what do you mean? shall i remove // << That one?
Reply
#7

Quote:
Originally Posted by showarn
Посмотреть сообщение
what do you mean?
pawn Код:
//SaveCars();
Remove the "//" in the codes above(that's what uncomment means)
Reply
#8

Alright ill try that!!
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)