Clickable textdraw CarEngine
#1

Does someone know how to make a Clickable textdraw for engine?
I did try but it wont work :/

If you step in the car it shows the textdraw then you click on start you drive away and when you stop it show the textdraw again and then you can click on stop to stop the engine?
Reply
#2

You will need a speedometer to do such thing so you can check every 500 mili seconds with a timer if the speed is below 5.
Reply
#3

I have a speedometer, and i check the speed, but when i stop the textdraw come back but then i can't move, and start/stop button doesnt work

http://pastebin.com/4n3ddGdC
Reply
#4

Could you show the code?
Reply
#5

http://pastebin.com/4n3ddGdC
Reply
#6

This should work:

pawn Код:
// Ongamemodeinit
for(new i = 0; i < MAX_PLAYERS; i++)
{
        TextDrawSetSelectable(EngineStart[i], true);
        TextDrawSetSelectable(EngineStop[i], true);
}

// OnPlayerStateChange
if(IsCar(vehiclemodel) || IsMotorCycle(vehiclemodel) || IsBoat(vehiclemodel))
{
        TextDrawShowForPlayer(playerid, EngineStart[playerid]);
        TextDrawShowForPlayer(playerid, EngineStop[playerid]);
        SelectTextDraw(playerid, RED);
}

public OnPlayerClickTextDraw(playerid, Text:clickedid)
{
    new vehicle = GetPlayerVehicleID(playerid);
        new lights, alarm, doors, bonnet, boot;

        if (clickedid != Text:INVALID_TEXT_DRAW)
    {
        if(clickedid == EngineStart[playerid])
            {
             SetVehicleParamsEx(vehicle, 1, lights, alarm, doors, bonnet, boot, 0);
                         TextDrawShowForPlayer(playerid,speed[playerid]);
        }
            else if(clickedid == EngineStop[playerid])
        {
                 SetVehicleParamsEx(vehicle, 0, lights, alarm, doors, bonnet, boot, 0);
        }
        CancelSelectTextDraw(playerid);
        }
    return 1;
}

public SpeedoUpdate()
{
        for(new i = 0;i<MAX_PLAYERS;i++)
        {
                if(IsPlayerConnected(i) && IsPlayerInAnyVehicle(i))
                {
                        new Float:x,Float:y,Float:z,string[24],vehicleid = GetPlayerVehicleID(i);
                        GetVehicleVelocity(vehicleid,x,y,z);
                        format(string,sizeof(string),"%d~w~km/h", GetPlayerSpeed(i, true));//floatround(floatsqroot(((x*x)+(y*y))+(z*z))*250.666667));
                        TextDrawSetString(speed[i],string);
                        if(GetPlayerSpeed(i, true) >= 2)
                        {
                            TextDrawHideForPlayer(i, EngineStop[i]);
                                                        SelectTextDraw(playerid, 0xFF0000FF);
                        }
                        else
                        {
                            TextDrawShowForPlayer(i, EngineStart[i]);
                            SelectTextDraw(playerid, 0xFF0000FF);
                        }
                }
                if(!IsPlayerInAnyVehicle(i))
                {
                        TextDrawHideForPlayer(i,speed[i]);
                }
        }
}
Reply
#7

What you post is wrong sir
I did send him a PM but he don't answer
Reply
#8

Quote:
Originally Posted by sjvt
Посмотреть сообщение
What you post is wrong sir
I did send him a PM but he don't answer
Well explain what is wrong.
Reply
#9

Quote:
Originally Posted by SomebodyAndMe
Посмотреть сообщение
Well explain what is wrong.
I did test it, its not clickable

sjvt i have no message received
Reply
#10

This should work:

pawn Код:
// Ongamemodeinit
for(new i = 0; i < MAX_PLAYERS; i++)
{
        TextDrawSetSelectable(EngineStart[i], 1);
        TextDrawSetSelectable(EngineStop[i], 1);
}

// OnPlayerStateChange
if(IsCar(vehiclemodel) || IsMotorCycle(vehiclemodel) || IsBoat(vehiclemodel))
{
        TextDrawShowForPlayer(playerid, EngineStart[playerid]);
        TextDrawShowForPlayer(playerid, EngineStop[playerid]);
        SelectTextDraw(playerid, RED);
}

public OnPlayerClickTextDraw(playerid, Text:clickedid)
{
    new vehicle = GetPlayerVehicleID(playerid);
        new lights, alarm, doors, bonnet, boot;

        if (clickedid != Text:INVALID_TEXT_DRAW)
    {
        if(clickedid == EngineStart[playerid])
            {
             SetVehicleParamsEx(vehicle, 1, lights, alarm, doors, bonnet, boot, 0);
                         TextDrawShowForPlayer(playerid,speed[playerid]);
        }
            else if(clickedid == EngineStop[playerid])
        {
                 SetVehicleParamsEx(vehicle, 0, lights, alarm, doors, bonnet, boot, 0);
        }
        CancelSelectTextDraw(playerid);
        }
    return 1;
}

public SpeedoUpdate()
{
        for(new i = 0;i<MAX_PLAYERS;i++)
        {
                if(IsPlayerConnected(i) && IsPlayerInAnyVehicle(i))
                {
                        new Float:x,Float:y,Float:z,string[24],vehicleid = GetPlayerVehicleID(i);
                        GetVehicleVelocity(vehicleid,x,y,z);
                        format(string,sizeof(string),"%d~w~km/h", GetPlayerSpeed(i, true));//floatround(floatsqroot(((x*x)+(y*y))+(z*z))*250.666667));
                        TextDrawSetString(speed[i],string);
                        if(GetPlayerSpeed(i, true) >= 2)
                        {
                            TextDrawHideForPlayer(i, EngineStop[i]);
TextDrawSetSelectable(EngineStart[i], 1);
                                                        SelectTextDraw(playerid, 0xFF0000FF);
                        }
                        else
                        {
                            TextDrawShowForPlayer(i, EngineStop[i]);
                            SelectTextDraw(playerid, 0xFF0000FF);
 TextDrawSetSelectable(EngineStop[i], 1);
                        }
                }
                if(!IsPlayerInAnyVehicle(i))
                {
                        TextDrawHideForPlayer(i,speed[i]);
                }
        }
}
Not tested
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)