Las Used vehicle
#1

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])
Reply
#2

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
Reply
#3

Thanks it works fine
Reply
#4

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.
}
Reply
#5

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
Reply
#6

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
Reply
#7

Quote:
Originally Posted by Don Correlli
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
Thank you for the link. Now I get it. I will definitely use Pvars on future :P
Reply
#8

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.
Reply
#9

So should you pretty much always use these from now on instead of creating those large arrays?
Reply
#10

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
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)