SA-MP Forums Archive
Vehicle ID - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Vehicle ID (/showthread.php?tid=467851)



Vehicle ID - MrMou6 - 05.10.2013

Hello, can I get vehicle ID after that I creat it:
Код:
AddStaticVehicle(AddStaticVehicle(carID, X,Y,Z,A, c1, c2);
// GetVehicleID...



Re: Vehicle ID - RajatPawar - 05.10.2013

pawn Код:
new veh_ID = AddStaticVehicle( ... )



Re: Vehicle ID - MrMou6 - 05.10.2013

I get this warning:
warning 204: symbol is assigned a value that is never used: "veh_ID"


Re: Vehicle ID - RajatPawar - 05.10.2013

Well, unless you use that veh_ID variable for a cause, it's gonna return the warning. So use it for something.


Re: Vehicle ID - DanishHaq - 05.10.2013

Quote:
Originally Posted by MrMou6
Посмотреть сообщение
I get this warning:
warning 204: symbol is assigned a value that is never used: "veh_ID"
That's because you've never used it in your script, once you use it somewhere, it'll work, i.e.:

pawn Код:
new car1;

public OnGameModeInit()
{
   car1 = CreateVehicle(...);
   return 1;
}
This will return that warning 204.

pawn Код:
new car1;

public OnGameModeInit()
{
   car1 = CreateVehicle(...);
   return 1;
}

public OnPlayerUpdate(playerid)
{
   if(GetPlayerVehicleID(playerid) == car1) return RemovePlayerFromVehicle(playerid);
   return 1;
}
Now the value of car1 has been used here, so it won't return any errors / warnings.


Re: Vehicle ID - Patrick - 05.10.2013

Quote:
Originally Posted by DanishHaq
Посмотреть сообщение
That's because you've never used it in your script, once you use it somewhere, it'll work, i.e.:

pawn Код:
new car1;

public OnGameModeInit()
{
   car1 = CreateVehicle(...);
   return 1;
}
This will return that warning 204.

pawn Код:
new car1;

public OnGameModeInit()
{
   car1 = CreateVehicle(...);
   return 1;
}

public OnPlayerUpdate(playerid)
{
   if(GetPlayerVehicleID(playerid) == car1) return RemovePlayerFromVehicle(playerid);
   return 1;
}
Now the value of car1 has been used here, so it won't return any errors / warnings.
You could just simple use OnPlayerEnterVehicle or OnPlayerStateChange

Example
pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER)
    {
        if(GetPlayerVehicleID(playerid) == car1)  return RemovePlayerFromVehicle(playerid);
    }
    return 1;
}