Whats wrong with this?
#1

I have this code for my private cars. So if someone has lent someone a car they can drive it also..
This is my code:

pawn Код:
if(vehicleid == Torran[0])
        {
            if(strcmp(GetName(playerid), "JoeTorran", true) == 0 || strcmp(Lent[playerid], "Torran0", true) == 0)
            {
                print(" ");
            }
            else
            {
                RemovePlayerFromVehicle(playerid);
            }
        }
But if someone gets in my car. It dosent remove them like they have it lent to them.
Why? OnPlayerConnect i set Lent[playerid] to 0, Anything wrong with that code?
Reply
#2

Are you using this code in the OnPlayerEnterVehicle callback? If so, it won't work. That callback (CB for short) gets called when the player presses the key for entering a vehicle ('F' by default), not when he actually 'enters' it. Use either OnPlayerStateChange with 'if(newstate == PLAYER_STATE_DRIVER && !strcmp(getname(playerid), "JoeTorran"))' or place the code on an even better place: OnVehicleStreamIn

pawn Код:
public OnVehicleStreamIn(vehicleid, forplayerid)
{
  if(vehicleid == Torran[0])
  {
    if(strcmp(GetName(forplayerid), "JoeTorran") || strcmp(Lent[forplayerid], "Torran0")) return SetVehicleParamsForPlayer(vehicleid, forplayerid, 0, 1);
  }
  return 1;
}
PS: Hope that code works lol
Reply
#3

I use it OnPlayerStateChange.
But if delete the Lent bit then it all works
Reply
#4

Could you show us any code about the 'Lent' bit?
Reply
#5

Quote:
Originally Posted by Hiddos
Посмотреть сообщение
Could you show us any code about the 'Lent' bit?
I PM'ed the code
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)