26.04.2017, 11:12
(
Последний раз редактировалось GeorgeMcReary; 26.04.2017 в 11:45.
)
Hello all. i created a Textdraw based Speedometer system. but i am having some trouble with it.
1> Engine,Speed,Gas and Car ID Text Draws does not get showed. idk what is wrong.
2>The Textdraws for Speed,Engine and Gas are not getting updated either.
i use ptask to Check the Speed each second but idk where to call it. can you please help me?
Thanks
BTW all the common labels like "Car ID:", "Gas:" etc are Global TDs(as they are same with each people) and the Values of those are Player TDs as they change with each player.
Here is my code for ShowSpeedo Under OnPlayerStateChange and also the ptast code for speed and Gas Update.
idk may be i am not calling ptask callback somewhere thats why its not working. so if thats the case please tell me where to call it and how?
Please Help me
1> Engine,Speed,Gas and Car ID Text Draws does not get showed. idk what is wrong.
2>The Textdraws for Speed,Engine and Gas are not getting updated either.
i use ptask to Check the Speed each second but idk where to call it. can you please help me?
Thanks
BTW all the common labels like "Car ID:", "Gas:" etc are Global TDs(as they are same with each people) and the Values of those are Player TDs as they change with each player.
Here is my code for ShowSpeedo Under OnPlayerStateChange and also the ptast code for speed and Gas Update.
idk may be i am not calling ptask callback somewhere thats why its not working. so if thats the case please tell me where to call it and how?
PHP код:
//Timer
ptask SpeedoCheck[1000](playerid)
{
if((GetPlayerState(playerid) == PLAYER_STATE_DRIVER || GetPlayerState(playerid) == PLAYER_STATE_PASSENGER) && PlayerInfo[playerid][pSpeedoOn] == 1) {
new veh = GetPlayerVehicleID(playerid);
new Float:Speed = GetVehicleSpeed(veh, 0);
new stringa[10],stringb[10];
if(!IsABicycle(veh))
{
format(stringa,sizeof(stringa),"%d Mph ",floatround(Speed/1.609));
PlayerTextDrawSetString(playerid,SpeedoP[playerid][7],stringa);
PlayerTextDrawShow(playerid, SpeedoP[playerid][7]);
format(stringb, sizeof(stringb), "%f ",Gas[veh]);
PlayerTextDrawSetString(playerid, SpeedoP[playerid][4], stringb);
PlayerTextDrawShow(playerid, SpeedoP[playerid][4]);
}
}
return 1;
}
PHP код:
//ShowSpeedo Code.
stock ShowSpeedo(playerid)
{
new veh = GetPlayerVehicleID(playerid);
new engine,lights,alarm,doors,bonnet,boot,objective;
new string[5],stringa[5],stringb[5],stringc[6];
GetVehicleParamsEx(veh,engine,lights,alarm,doors,bonnet,boot,objective);
if(!IsABicycle(veh) && PlayerInfo[playerid][pTogSpeedo] == 0)
{
for(new i=0;i<9;i++)
{
TextDrawShowForPlayer(playerid, SpeedoG[i]);
}
PlayerTextDrawSetString(playerid, SpeedoP[playerid][0], GetVehicleName(veh));
PlayerTextDrawShow(playerid, SpeedoP[playerid][0]);
if(engine == VEHICLE_PARAMS_ON)
{
format(string, sizeof(string), "ON");
PlayerTextDrawSetString(playerid, SpeedoP[playerid][1], string);
}
PlayerTextDrawShow(playerid, SpeedoP[playerid][1]);
PlayerTextDrawShow(playerid, SpeedoP[playerid][2]);
PlayerTextDrawShow(playerid, SpeedoP[playerid][3]);
format(stringa, sizeof(stringa), "%f ",Gas[veh]);
PlayerTextDrawSetString(playerid, SpeedoP[playerid][4], stringa);
PlayerTextDrawShow(playerid, SpeedoP[playerid][4]);
PlayerTextDrawShow(playerid, SpeedoP[playerid][5]);
format(stringb, sizeof(stringb), "%d",veh);
PlayerTextDrawSetString(playerid, SpeedoP[playerid][6], stringb);
PlayerTextDrawShow(playerid, SpeedoP[playerid][6]);
//format(stringc, sizeof(stringc), "0 Mph");
PlayerTextDrawSetString(playerid, SpeedoP[playerid][7], "0 Mph");
PlayerTextDrawShow(playerid, SpeedoP[playerid][7]);
PlayerInfo[playerid][pSpeedoOn] =1;
}
}