Need help with a fuel variable not working and setting vOwner
#1

Not beeen here for help in a long time Though I have this bug which is bugging me (pun), basically when I'm setting the vFuel for a vehicle upon spawning, when I attempt to turn the car on it just says out of fuel. This has only been a problem since I have moved the fuel variable from an independent global variable to an enum array variable:

This function loads the players owned vehicles upon login. It loads and spawns the vehicles correctly, though when I set the fuel it doesn't want to work, neither does setting the vehicle owners name:

Код:
	public onLoadPlayerVehicles(playerid)
	{
		new rows, fields, vid, tmpstring[26];
		
		cache_get_data(rows, fields);
		
		if(rows)
		{
			for(new i = 0; i < 5; i++)
			{
				Vehicle[vid][Model] = cache_get_field_content_int(i, "Model");
			
				cache_get_field_content(i, "Owner", tmpstring);
				
				strpack(Vehicle[vid][Owner], tmpstring);
				
				
				Vehicle[vid][Position][0] = cache_get_field_content_float(i, "VehX");
				Vehicle[vid][Position][1] = cache_get_field_content_float(i, "VehY");
				Vehicle[vid][Position][2] = cache_get_field_content_float(i, "VehZ");
				Vehicle[vid][Position][3] = cache_get_field_content_float(i, "VehA");
				Vehicle[vid][vFuel] = cache_get_field_content_int(i, "Fuel");
				
				Vehicle[vid][Color][0] = cache_get_field_content_int(i, "Color1");
				Vehicle[vid][Color][1] = cache_get_field_content_int(i, "Color2");
				//CreateVehicle(vehtype, x, y, z, a, cl1, cl2, 0);
				CreateVehicle(Vehicle[vid][Model], Vehicle[vid][Position][0], Vehicle[vid][Position][1], Vehicle[vid][Position][2], Vehicle[vid][Position][3],
								Vehicle[vid][Color][0], Vehicle[vid][Color][1], 0);
								
				printf("(%d on the list) The vehicle was apparently created and sits at %f : %f : %f and is owned by %s and has %d fuel.", i, Vehicle[vid][Position][0], Vehicle[vid][Position][1], Vehicle[vid][Position][2], Vehicle[vid][Owner], Vehicle[vid][vFuel]);
			}
		}
		else
		{
			print ("No rows");
		}
		return 1;
	}
This code executes upon turning the engine on:

Код:
		if(PRESSED(KEY_YES))
		{
			if(IsPlayerInAnyVehicle(playerid) && GetPlayerVehicleSeat(playerid) == 0)
			{
				new vid = GetPlayerVehicleID(playerid), engine, lights, alarm, doors, bonnet, boot, objective;
				GetVehicleParamsEx(vid, engine, lights, alarm, doors, bonnet, boot, objective);
				SetVehicleParamsEx(vid, 0, lights, alarm, doors, bonnet, boot, objective);
				
				new Float:Pos[3];
				GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
				
				if(!engine)
				{
					GameTextForPlayer(playerid, "Turning engine on...", 1500, 3);
					SetTimerEx("EngineOn", 1000, false, "id", playerid, vid);
				}
				else
				{
					SetVehicleParamsEx(vid, 0, lights, alarm, doors, bonnet, boot, objective);
					GameTextForPlayer(playerid, "~r~Engine Off~w~", 1500, 3);
					PlayerPlaySound(playerid, 1138, Pos[0], Pos[1], Pos[2]);
					
					//KillTimer(FuelTimer[playerid]);
					//KillTimer(SpeedoTimer[playerid]);
				}
			}
		}
Finally, the FuelUpdate timer, which doesn't get a chance to execute but im going to throw it in anyways:

Код:
	public FuelUpdate(playerid, vehicleid)
	{
		if(Engine[vehicleid] != 0)
		{
				
			if(Vehicle[vehicleid][vFuel] <= 1)
			{
				new engine, lights, alarm, doors, bonnet, boot, objective;
				
				GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
				Fuel[vehicleid] = 0;
				SendClientMessage(playerid, -1, "You have ran out of fuel.");
				SetVehicleParamsEx(vehicleid, 0, lights, alarm, doors, bonnet, boot, objective);
				
				//KillTimer(SpeedoTimer[playerid]);
				//KillTimer(FuelTimer[playerid]);
				
			}
			else
			{
				Vehicle[vehicleid][vFuel] -= 1;
				
				new string[50];
				
				format(string, sizeof(string), "%d", Fuel[vehicleid]);
				PlayerTextDrawSetString(playerid, TDSPEEDO[playerid][5], string);
			}
		}
	
	}
If anyone can show me where I'm going wrong I'd appreciate it, not scripted in a while.
Reply
#2

Anyone see the problem?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)