Clickable textdraw CarEngine
#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


Messages In This Thread
Clickable textdraw CarEngine - by johannes95 - 12.04.2012, 14:19
Re: Clickable textdraw CarEngine - by SomebodyAndMe - 12.04.2012, 14:36
Re: Clickable textdraw CarEngine - by johannes95 - 12.04.2012, 14:49
Re: Clickable textdraw CarEngine - by SomebodyAndMe - 12.04.2012, 14:53
Re: Clickable textdraw CarEngine - by johannes95 - 12.04.2012, 14:54
Re: Clickable textdraw CarEngine - by SomebodyAndMe - 12.04.2012, 15:04
Re: Clickable textdraw CarEngine - by sjvt - 12.04.2012, 15:12
Re: Clickable textdraw CarEngine - by SomebodyAndMe - 12.04.2012, 15:16
Re: Clickable textdraw CarEngine - by johannes95 - 12.04.2012, 15:16
Re: Clickable textdraw CarEngine - by SomebodyAndMe - 12.04.2012, 15:21

Forum Jump:


Users browsing this thread: 3 Guest(s)