11.08.2011, 08:34
Hi peoples.I need some help with me gas system,and player run with vehicle distance,i get that with this variable:
Then OnPlayerStateChange:
But when passed 60000(milli seconds(1 min)),i not lose 0.1 gas,but i only get this message:
But i run with vehicle a lot of time and it's more than 0.1 distance...And if you ask is this variable show vehicle distance i say yes because i set another taimer for 1 sec,and after them:
And i get textdraw with vehicle distance and this is good.But how i say in the top,maybe some thing is bad with pvars
Код:
vehicleDB[vehicleid][prav]/10000);//Vehicle all distance.
Код:
if(newstate == PLAYER_STATE_DRIVER) { SetPVarFloat(vehicleid,"PravBefore",vehicleDB[vehicleid][prav]/10000); SetTimerEx("Speed",60000,true,"i",playerid); }
Код:
public Speed(playerid) { if(model != 481 && model != 510 && model != 509)//if not bikes { if(vehicleDB[vehicleid][gas] > 2)// if more than 2 gas { SetPVarFloat(vehicleid,"PravAfter",vehicleDB[vehicleid][prav]/10000);//Other pvar who i set after prav(vehicle distance). if(GetPVarFloat(vehicleid,"PravBefore") + GetPVarFloat(playerid,"PravAfter") >= 0.1) { vehicleDB[vehicleid][gas] -=0.1; return 1; } SendClientMessage(playerid,COLOR_GREEN,"Before prav has been set"); SetPVarFloat(vehicleid,"PravBefore",vehicleDB[vehicleid][prav]/10000); // Save the float into a player variable } } return 1; }
Код:
SendClientMessage(playerid,COLOR_GREEN,"Before prav has been set");
Код:
public Speed(playerid) { new String[64]; new vehicleid = GetPlayerVehicleID(playerid); new Float:ST[4]; GetVehicleVelocity(GetPlayerVehicleID(playerid),ST[0],ST[1],ST[2]); ST[3] = floatsqroot(floatpower(floatabs(ST[0]), 2.0) + floatpower(floatabs(ST[1]), 2.0) + floatpower(floatabs(ST[2]), 2.0)) * 180.3; vehicleDB[vehicleid][prav] += ST[3]; format(String, sizeof(String), "Vehicle distance: %.1f",vehicleDB[vehicleid][prav]/10000); TextDrawSetString(VehicleDistance[playerid], String); TextDrawShowForPlayer(playerid, VehicleDistance[playerid]); }