[Help] Show vehicle model when player enters vehicle.
#1

Hello, I need help doing something. I wanna show the vehicle model when a player enters the vehicle. But for the way I know, I'd have to do 212 textdraws lol. So... is there any other way to do it?

An example:
pawn Code:
new Text:car0;

public OnGameModeInit()
{
car0 = TextDrawCreate(497.000000, 270.000000, "sup?");
TextDrawBackgroundColor(car0, 0x00000044);
TextDrawFont(car0, 5);
TextDrawLetterSize(car0, 0.500000, 1.000000);
TextDrawColor(car0, -1);
TextDrawSetOutline(car0, 0);
TextDrawSetProportional(car0, 1);
TextDrawSetShadow(car0, 1);
TextDrawUseBox(car0, 1);
TextDrawBoxColor(car0, 0x00000044);
TextDrawTextSize(car0, 111.000000, 92.000000);
TextDrawSetPreviewModel(car0, 400);
TextDrawSetPreviewRot(car0, -16.000000, 0.000000, -55.000000, 1.000000);
TextDrawSetSelectable(car0, 0);
return 1;
}

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{

new model = GetVehicleModel( vehicleid );
if (model == 400)
{
TextDrawShowForPlayer(playerid, car0);
}
return 1;
}
Reply
#2

it would be easier to use GameTextForPlayer.
But if you want to use textdraws, than just change string of the textdraw using TextDrawSetString.
Reply
#3

Use TextDrawSetString.

pawn Code:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger) {
    new model = GetVehicleModel( vehicleid );
    if (model == 520) TextDrawSetString(car, "Hydra");
    return true;
}
Only takes 1 TD, also I'd like to point out you can make an array with all vehicles and do this in just a few lines of code.
Reply
#4

Quote:
Originally Posted by dominik523
View Post
it would be easier to use GameTextForPlayer
Can you show the model with GameText?

Quote:
Originally Posted by Mean
View Post
But how?
Reply
#5

It's fine with just 1 textdraw, just use TextDrawSetString.

pawn Code:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if (newstate == PLAYER_STATE_DRIVER)
    {
        new
            modelid = GetVehicleModel(GetPlayerVehicleID(playerid));
        if (modelid)
        {
            // format a string and pass the modelid as an argument and then use TextDrawSetString to update the string
            TextDrawShowForPlayer(playerid, car0);
        }
    }
    return 1;
}
It's also better to use per-player textdraws for such as things.
Reply
#6

Quote:
Originally Posted by Konstantinos
View Post
It's fine with just 1 textdraw, just use TextDrawSetString.

pawn Code:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if (newstate == PLAYER_STATE_DRIVER)
    {
        new
            modelid = GetVehicleModel(GetPlayerVehicleID(playerid));
        if (modelid)
        {
            // format a string and pass the modelid as an argument and then use TextDrawSetString to update the string
            TextDrawShowForPlayer(playerid, car0);
        }
    }
    return 1;
}
It's also better to use per-player textdraws for such as things.
Works but shows the same model for all vehicles .
Reply
#7

Quote:
Originally Posted by iDuckling
View Post
Works but shows the same model for all vehicles .
Help please.

Quote:
Originally Posted by Mean
View Post
Use TextDrawSetString.

pawn Code:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger) {
    new model = GetVehicleModel( vehicleid );
    if (model == 520) TextDrawSetString(car, "Hydra");
    return true;
}
Only takes 1 TD, also I'd like to point out you can make an array with all vehicles and do this in just a few lines of code.
For that GameText will be better. What I'm trying to do is show the model (a little image of the vehicle). Like this:
Reply
#8

Quote:
Originally Posted by iDuckling
View Post
Works but shows the same model for all vehicles .
What model does it show? Can you post the part you format the model and you update the string of the textdraw?
Reply
#9

Quote:
Originally Posted by Konstantinos
View Post
What model does it show? Can you post the part you format the model and you update the string of the textdraw?
I pasted the code you gave me, I have not done any of that. How do I do it? I'm new so suck at this haha thanks for all the help.
Reply
#10

Yeah! I did it!!! Thanks a lot Konstantinos, and thanks to everyone who tried to help me, thank youuuu! +rep .
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)