10.05.2014, 21:30
(
Last edited by Aerotactics; 11/05/2014 at 05:57 AM.
)
So, I'm building a vehicle script for my server, and it's nearly done, besides some bug fixes. This bug I'm not sure how to fix, and I didn't want to go trying something just to have it not work. Thanks for your help.
New Issue:Fixed the flickering, but the gas just doesn't work. After doing "/fix gas" the gas doesn't change.
Quote:
ISSUE: When I go to refill the vehicle's gas, instead of adding to the vehicle's existing data, it creates new data, and shows a second flickering 3d text label. |
pawn Code:
CMD:fix(playerid, params[])
{
if(!IsPlayerInAnyVehicle(playerid)) return SCM(playerid,COLOR_GREY, "You are not in a vehicle.");
new str[16];
if(sscanf(params,"s[16]",str)) return SCM(playerid,COLOR_WHITE, "Usage: /fix [engine/tire/gas]");
new vehicleid = GetPlayerVehicleID(playerid);
for(new i=0;i<MAX_VEHICLES;i++)
{
if(vehicleid == DynVehicle[i])
{
...
if(!strcmp(str,"gas",true,3))
{
ToggleEngine(playerid,vehicleid,false);
TIMER_GASFILL[playerid] = SetTimer("GasTimer",GAS_FILL,true);
SCM(playerid,COLOR_WHITE, "You start pouring gas into the tank. Exit the vehicle to stop pouring gas.");
}
}
}
return 1;
}
public GasTimer(playerid)
{
new vehicleid = GetPlayerVehicleID(playerid);
if (partInfo[playerid][gas] == 0)
{
KillTimer(TIMER_GASFILL[playerid]);
SCM(playerid,COLOR_WHITE, "You are out of stored fuel.");
return 1;
}
else if(vInfo[vehicleid][gas] == 100)
{
KillTimer(TIMER_GASFILL[playerid]);
SCM(playerid,COLOR_WHITE, "Gas tank is full.");
return 1;
}
else
{
partInfo[playerid][gas] -= 1;
vInfo[vehicleid][gas] += 1;
UpdateText(playerid,vehicleid);
}
return 1;
}
stock UpdateText(playerid,vehicleid)
{
new str[128];
format(str,sizeof(str),"Engine: %.0f\nTires: %i\nGas: %i", vInfo[vehicleid][engine],vInfo[vehicleid][tires],vInfo[vehicleid][gas]);
for(spawncar=0;spawncar<sizeof(vSpawns);spawncar++)
{
if(IsPlayerInVehicle(playerid,DynVehicle[spawncar])){Update3DTextLabelText(CarInfo[spawncar],COLOR_WHITE,str);}
}
return 1;
}