SetVehicleNumberPlate does not work for me
#1

pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    new name[32], VID;
    VID = GetPlayerVehicleID(playerid);
    GetPlayerName(playerid,name,sizeof(name));
    SetVehicleNumberPlate(VID,name);
        SetVehicleToRespawn(VID);
    return 1;
}
No effect... Does not set the name, does not respawn either... wtf?
Reply
#2

GetPlayerVehicleID will return 0 when OnPlayerEnterVehicle is called because the player is not in that vehicle at that time, so that's why it doesn't work. You have the vehicleid parameter there, why don't you use it ?
Reply
#3

Quote:
Originally Posted by [NoV]LaZ
Посмотреть сообщение
GetPlayerVehicleID will return 0 when OnPlayerEnterVehicle is called because the player is not in that vehicle at that time, so that's why it doesn't work. You have the vehicleid parameter there, why don't you use it ?
Sorry I dont get it ;|
Reply
#4

He means you have to do it this way:
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    new
        name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    SetVehicleNumberPlate(vehicleid, name);
    SetVehicleToRespawn(vehicleid);
    return 1;
}
Please note that if the player enters the vehicle and it's moved from it's original spawning position it won't respawn where the player is. This can be avoided by doing this:
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    new
        name[MAX_PLAYER_NAME], vx, vy, vz;
    GetPlayerName(playerid, name, sizeof(name));
    SetVehicleNumberPlate(vehicleid, name);
    SetVehicleToRespawn(vehicleid);
    SetVehiclePos(vehicleid, vx, vy, vz);
    PutPlayerInVehicle(playerid, vehicleid, 0);
    return 1;
}
Reply
#5

Quote:
Originally Posted by Not available
Посмотреть сообщение
He means you have to do it this way:
Please note that if the player enters the vehicle and it's moved from it's original spawning position it won't respawn where the player is. This can be avoided by doing this:
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    new
        name[MAX_PLAYER_NAME], vx, vy, vz;
    GetPlayerName(playerid, name, sizeof(name));
    SetVehicleNumberPlate(vehicleid, name);
    SetVehicleToRespawn(vehicleid);
    SetVehiclePos(vehicleid, vx, vy, vz);
    PutPlayerInVehicle(playerid, vehicleid, 0);
    return 1;
}
works now...
but another problem now...
when I use a command like /car .. it puts me in to the vehicle automaticly...
but when i leave the vehicle it dissapears... o.O
Reply
#6

Are you setting the vehicle to clear nameplate and respawn when player exits the vehicle?
Reply
#7

Quote:
Originally Posted by Not available
Посмотреть сообщение
Are you setting the vehicle to clear nameplate and respawn when player exits the vehicle?
nope..
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)