new string on TextDrawSetPreviewModel
#1

Franзais :
Bonjours,

J'aimerai obtenir l'idmodel du vйhicule du (playerid) pour modifier un TextDrawSetPreviewModel.
Voici le code que j'ai voulu faire :

English
Hellos,

I'd like to get idmodel the vehicle (playerid) to change a TextDrawSetPreviewModel.
Here is the code I wanted to do:
(excuse me for my english I'm french)


PHP код:
2721 public OnPlayerEnterVehicle(playeridvehicleidispassenger)
2722 {
2723       TextDrawShowForPlayer(playerid,TextVeh);
2724       new string[10];
2725       format(string,sizeof(string),"%d",GetVehicleModel(vehicleid));
2726       TextDrawSetPreviewModel(TextVehstring);
2727          return 1;
2728 
Mais j'ai une erreurs :

But I have an error:

PHP код:
C:\Users\Alexis\Dropbox\Serveur\gamemodes\Truckserv.pwn(2726) : error 035argument type mismatch (argument 2
(Le TextVeh est bien dйfini par un new .... )

(The TextVeh is defined by a new ....)

Pourriez vous m'aider s'il vous plaоt ? Je vous remerci d'avance

Could you help me please? Thank you in advance I
Reply
#2

You don't need to format it into a string, that is enough
Also use OnPlayerStateChange instead of OnPlayerEnterVehicle
Because OnPlayerEnterVehicle gets called if you want to enter a vehicle (you could still abort that halfway)
Third, you should use PlayerTextDraw instead of global ones otherwise the textdraw will be overwritten each time a players enters a vehicle

pawn Код:
// OnPlayerStateChange
    if(newstate == PLAYER_STATE_DRIVER) {
        TextDrawSetPreviewModel(TextVeh, GetVehicleModel(vehicleid));
        TextDrawShowForPlayer(playerid, TextVeh);
    }
    if(oldstate == PLAYER_STATE_DRIVER) {
        TextDrawHideForPlayer(playerid, TextVeh);
    }
Reply
#3

Quote:

You don't need to format it into a string, that is enough
Also use OnPlayerStateChange instead of OnPlayerEnterVehicle
Because OnPlayerEnterVehicle gets called if you want to enter a vehicle (you could still abort that halfway)
Third, you should use PlayerTextDraw instead of global ones otherwise the textdraw will be overwritten each time a players enters a vehicle

pawn Code:
// OnPlayerStateChange
if(newstate == PLAYER_STATE_DRIVER) {
TextDrawSetPreviewModel(TextVeh, GetVehicleModel(vehicleid));
TextDrawShowForPlayer(playerid, TextVeh);
}
if(oldstate == PLAYER_STATE_DRIVER) {
TextDrawHideForPlayer(playerid, TextVeh);
}
__________________

Super thank you the only problem is that its not take me the id and makes me a skin (watch this screen, http://prntscr.com/3g5y7g). I tried to just put an id of car is it works but suddenly it's always the same.

That I put :

PHP код:
public OnPlayerStateChange(playerid,newstate,oldstate)
{
    new 
vehicleid GetVehicleModel (playerid);
    if(
newstate == PLAYER_STATE_DRIVER)
    {
        
TextDrawSetPreviewModel(TextVehGetVehicleModel(vehicleid));
        
TextDrawShowForPlayer(playeridTextVeh);
        }
    if(
oldstate == PLAYER_STATE_DRIVER)
    {
        
TextDrawHideForPlayer(playeridTextVeh);
        }
    return 
1;

Reply
#4

Well you used the wrong function to get the vehicle id
You need to use GetPlayerVehicleID for that
pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER)
    {
        new vehicleid = GetPlayerVehicleID(playerid);
        new modelid = GetVehicleModel(vehicleid);
        TextDrawSetPreviewModel(TextVeh, modelid);
        TextDrawShowForPlayer(playerid, TextVeh);
    }
    if(oldstate == PLAYER_STATE_DRIVER)
    {
        TextDrawHideForPlayer(playerid, TextVeh);
    }
    return 1;
}
Reply
#5

Quote:

Well you used the wrong function to get the vehicle id
You need to use GetPlayerVehicleID for that
pawn Code:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == PLAYER_STATE_DRIVER)
{
new vehicleid = GetPlayerVehicleID(playerid);
new modelid = GetVehicleModel(vehicleid);
TextDrawSetPreviewModel(TextVeh, modelid);
TextDrawShowForPlayer(playerid, TextVeh);
}
if(oldstate == PLAYER_STATE_DRIVER)
{
TextDrawHideForPlayer(playerid, TextVeh);
}
return 1;
}
_____

Super Nero_3D thank you it works!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)