Las Used vehicle - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Las Used vehicle (
/showthread.php?tid=143196)
Las Used vehicle -
graetz - 21.04.2010
Hello how to make it check if the old vehicle ID is Same as PlayerInfo[playerid][pPcarkey]

?
Код:
if( Last used vehicle ID == PlayerInfo[playerid][pPcarkey])
Re: Las Used vehicle -
CAR - 21.04.2010
I don't know if it works...
But I think so.
At the top:
pawn Код:
new LastUsedVeh[MAX_PLAYERS];
OnPlayerExitVehicle:
pawn Код:
public OnPlayerExitVehicle(playerid, vehicleid)
{
LastUsedVeh[playerid] = vehicleid;
return 1;
}
Now the last used vehicle id should be saved as: LastUsedVeh[playerid]
So you can use:
pawn Код:
if (LastUsedVeh[playerid] == PlayerInfo[playerid][pPcarkey])
But if the "PlayerInfo[playerid][pPcarkey]" isn't a vehicle ID this isn't the answer
Re: Las Used vehicle -
graetz - 21.04.2010
Thanks it works fine
Re: Las Used vehicle -
Correlli - 21.04.2010
I recommend to use the PVars.
pawn Код:
public OnPlayerExitVehicle(playerid, vehicleid)
{
SetPVarInt(playerid, "Last_Vehicle", vehicleid);
return true;
}
pawn Код:
if(GetPVarInt(playerid, "Last_Vehicle") == PlayerInfo[playerid][pPcarkey])
{
// your code.
}
Re: Las Used vehicle -
Goobiiify - 21.04.2010
Quote:
Originally Posted by Don Correlli
I recommend to use the PVars.
pawn Код:
public OnPlayerExitVehicle(playerid, vehicleid) { SetPVarInt(playerid, "Last_Vehicle", vehicleid); return true; }
pawn Код:
if(GetPVarInt(playerid, "Last_Vehicle") == PlayerInfo[playerid][pPcarkey]) { // your code. }
|
a personally question, why is Pvar good. I mean is it faster then the old way? :P
Re: Las Used vehicle -
Correlli - 21.04.2010
Quote:
Originally Posted by Al Fathead
a personally question, why is Pvar good. I mean is it faster then the old way? :P
|
https://sampwiki.blast.hk/wiki/Per-player_variable_system
Re: Las Used vehicle -
Goobiiify - 21.04.2010
Quote:
Originally Posted by Don Correlli
|
Thank you for the link. Now I get it. I will definitely use Pvars on future :P
Re: Las Used vehicle -
Correlli - 21.04.2010
Quote:
Originally Posted by Al Fathead
Thank you for the link. Now I get it. I will definitely use Pvars on future :P
|
You're welcome. Yes, you should indeed, they're much better in every way than normal MAX_PLAYERS sized arrays.
Re: Las Used vehicle -
Backwardsman97 - 21.04.2010
So should you pretty much always use these from now on instead of creating those large arrays?
Re: Las Used vehicle -
Nero_3D - 21.04.2010
I recommend OnPlayerKeyStateChange with oldstate == STATE_DRIVER (or how it gets called)
Because OnPlayerExitVehicle wont be called if you drop from your bike, it only gets called if you press the exit key