[Solved] Show vehicle model when player enters vehicle. -
iDuckling - 21.12.2013
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;
}
Re: [Help] Show vehicle model when player enters vehicle. -
dominik523 - 21.12.2013
it would be easier to use GameTextForPlayer.
But if you want to use textdraws, than just change string of the textdraw using TextDrawSetString.
Re: [Help] Show vehicle model when player enters vehicle. -
Mean - 21.12.2013
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.
Re: [Help] Show vehicle model when player enters vehicle. -
iDuckling - 21.12.2013
Quote:
Originally Posted by dominik523
it would be easier to use GameTextForPlayer
|
Can you show the model with GameText?
Quote:
Originally Posted by Mean
|
But how?
Re: [Help] Show vehicle model when player enters vehicle. -
Konstantinos - 21.12.2013
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.
Re: [Help] Show vehicle model when player enters vehicle. -
iDuckling - 21.12.2013
Quote:
Originally Posted by Konstantinos
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
.
Re: [Help] Show vehicle model when player enters vehicle. -
iDuckling - 22.12.2013
Quote:
Originally Posted by iDuckling
Works but shows the same model for all vehicles .
|
Help please.
Quote:
Originally Posted by Mean
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:
Re: [Help] Show vehicle model when player enters vehicle. -
Konstantinos - 22.12.2013
Quote:
Originally Posted by iDuckling
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?
Re: [Help] Show vehicle model when player enters vehicle. -
iDuckling - 22.12.2013
Quote:
Originally Posted by Konstantinos
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.
Re: [Help] Show vehicle model when player enters vehicle. -
iDuckling - 22.12.2013
Yeah! I did it!!! Thanks a lot Konstantinos, and thanks to everyone who tried to help me, thank youuuu! +rep
.