PDA

View Full Version : Doesn't show vehicle owner name


Sc0pion
06/07/2015, 06:45 PM
Fixed!

liquor
06/07/2015, 07:27 PM
It must be one of the variables (IsValidVehicle, VehicleCreated, VEHICLE_PLAYER, VehicleOwner) that fails, so the error
is probably somewhere where these are set. Make sure they're set so that the 'if' statements actually return 1.
Maybe you added a vehicle or changed the order, e.g. added a vehicle before so vehicle id's got screwed up.

But i can help you optimize your code in the meantime :)
Show us some code where all of those variables are set, and also where you create your vehicles.


public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
if(!ispassenger)
{
//new id = GetPlayerVehicleID(playerid); This is already defined in the callback, 'vehicleid' (remove this line)
if(IsValidVehicle(vehicleid) && VehicleCreated[vehicleid] == VEHICLE_PLAYER) // So i changed all 'id' to 'vehicleid'
{
new msg[45+MAX_PLAYER_NAME]; // This string will never be 256 cells big, so i changed it according to actual size.
format(msg, sizeof(msg), "[ NOTIFICATION: This vehicle belongs to %s. ]", VehicleOwner[vehicleid]);
SendClientMessage(playerid, COLOR_PURPLE, msg);
}
}
return 1;
}