SA-MP Forums Archive
Textdraw show when enter vehicle? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Textdraw show when enter vehicle? (/showthread.php?tid=528173)



Textdraw show when enter vehicle? - UserName31 - 26.07.2014

i dont know i did playertextdraw rite but still keep showing on playerenter vehicle i tryed to hide it but wont work

PHP код:
new PlayerText:PoliceO[MAX_PLAYERS]; 
onplayerspawn
PHP код:
PlayerTextDrawHide(playerid, PoliceO[playerid]); 
onaplayerConnect
PHP код:
    PoliceO[playerid] = CreatePlayerTextDraw(playerid,232.000000, 156.000000, "~b~~h~~h~~h~Police Officer ~w~~h~Job~b~~h~!");
    
PlayerTextDrawBackgroundColor(playerid,PoliceO[playerid], 255);
    
PlayerTextDrawFont(playerid,PoliceO[playerid], 3);
    
PlayerTextDrawLetterSize(playerid,PoliceO[playerid], 0.500000, 1.600000);
    
PlayerTextDrawColor(playerid,PoliceO[playerid], -1);
    
PlayerTextDrawSetOutline(playerid,PoliceO[playerid], 1);
    
PlayerTextDrawSetProportional(playerid,PoliceO[playerid], 1);
    
PlayerTextDrawSetSelectable(playerid,PoliceO[playerid], 0); 



Re : Textdraw show when enter vehicle? - S4t3K - 26.07.2014

If I figured out your problem the good way, a textdraw shows when a player enters a vehicle and you want to hide it ?

Under OnPlayerEnterVehicle, simply add your "PlayerTextDrawHide".
When a player enters a vehicle, he doesn't spawn. And it's the same when he exits.


Re: Re : Textdraw show when enter vehicle? - UserName31 - 26.07.2014

Quote:
Originally Posted by S4t3K
Посмотреть сообщение
If I figured out your problem the good way, a textdraw shows when a player enters a vehicle and you want to hide it ?

Under OnPlayerEnterVehicle, simply add your "PlayerTextDrawHide".
When a player enters a vehicle, he doesn't spawn. And it's the same when he exits.
i did that it dont work


Re : Textdraw show when enter vehicle? - S4t3K - 26.07.2014

Can you show us your OnPlayerStateChange and your OnPlayerEnterVehicle callback please ?

Because OnPlayerStateChange is called after OnPlayerEnterVehicle, if the textdraw is shown back in this callback, it's normal that you still show it.


Re: Re : Textdraw show when enter vehicle? - UserName31 - 27.07.2014

Quote:
Originally Posted by S4t3K
Посмотреть сообщение
Can you show us your OnPlayerStateChange and your OnPlayerEnterVehicle callback please ?

Because OnPlayerStateChange is called after OnPlayerEnterVehicle, if the textdraw is shown back in this callback, it's normal that you still show it.
onplayerenter vehicle
PHP код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    
AccountInfo[playerid][pLastVehicle] = 1;
     
TextDrawHideForPlayer(playerid, PoliceO[playerid]);
    return 
1;
} 
onplayerchangeupdate
PHP код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    new 
oname[MAX_PLAYER_NAME];
    
GetPlayerName(playerid, oname, sizeof oname);
    if(
newstate == PLAYER_STATE_DRIVER)
    {
        if (
IsArmyVehicle(GetPlayerVehicleID(playerid))) {
            if(
gTeam[playerid] !=Team_Army)
            {
                
RemovePlayerFromVehicle(playerid);
                
SendClientMessage(playerid, COLOR_RED, "You are not an Army official. You cannot drive/fly an army vehicle.");
                return 
1;
            }
        }
        if(
GetPlayerVehicleID(playerid) == House4Car1 || GetPlayerVehicleID(playerid) == House4Car2)
        {
            if(!
strcmp(House_Four_Owner, oname, true))
            {
                
SendClientMessage(playerid, COLOR_GREY, "Welcome to your vehicle!");
            }
            else {
                
RemovePlayerFromVehicle(playerid);
                
SendClientMessage(playerid, COLOR_RED, "This isn't your vehicle. You cannot drive it.");
                return 
1;
            }
        }
        if(
GetPlayerVehicleID(playerid) == House7Car1)
        {
            if(!
strcmp(House_Seven_Owner, oname, true))
            {
                
SendClientMessage(playerid, COLOR_GREY, "Welcome to your vehicle!");
            }
            else {
                
RemovePlayerFromVehicle(playerid);
                
SendClientMessage(playerid, COLOR_RED, "This isn't your vehicle. You cannot drive it.");
                return 
1;
            }
        }
        if(
GetPlayerVehicleID(playerid) == House6Car1)
        {
            if(
strcmp(House_Six_Owner, oname,true))
            {
                
RemovePlayerFromVehicle(playerid);
                
SendClientMessage(playerid, COLOR_RED, "This isn't your vehicle. You cannot drive it.");
                return 
1;
            }
            
SendClientMessage(playerid, COLOR_GREY, "Welcome to your vehicle!");
        }
        if (
IsLSPDVehicle(GetPlayerVehicleID(playerid))) {
            if(
gTeam[playerid] != Team_Cop && gTeam[playerid] != Team_Cop && gTeam[playerid] != Team_FBI && gTeam[playerid] != Team_Guard)
            {
                new 
string[120];
                
format(string, 120, "[CAR THEFT] %s has stolen a police vehicle.", PlayerInfo(playerid));
                
SendCopMessage(string);
                
format(string, 120, "Type /radiooff to turn off your police radio.");
                
SendCopMessage(string);
                
IncreaseWantedLevel(playerid, 4);
            }
        }
        if(
GetPlayerVehicleID(playerid) == AdminCar1 || GetPlayerVehicleID(playerid) == AdminCar2)
        {
            if(
AccountInfo[playerid][pAdminLevel] == 0)
            {
                
SendClientMessage(playerid, COLOR_ADMIN, "You cannot drive the Admin Vehicle.");
                
RemovePlayerFromVehicle(playerid);
                return 
1;
            }
            
SendClientMessage(playerid, COLOR_ADMIN, "Welcome to your Admin Only Vehicle!");
        }
    }
    if(
newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER) {
        
ShowPlayerSpeedo(playerid);
          
AccountInfo[playerid][pLastVehicle] = GetPlayerVehicleID(playerid);
    }
    if(
GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
    {
        
SendClientMessage(playerid, COLOR_LIME, "You have enter a vehicle do /vhelp for vehicle commands.");
    }
    return 
1;
}