Vehicle License Problem

Started by Kewun, Aug 10, 2016, 07:06 PM

Previous topic - Next topic

Kewun

local bmodels = [
175,
130,
131,
132,
134,
135,
139,
140,
141,
142,
145,
147,
148,
149,
150,
151,
152,
154,
156,
159,
164,
168,
172,
174,
175,
187,
188,
196,
197,
200,
201,
204,
205,
206,
207,
209,
210,
211,
216,
219,
220,
221,
222,
224,
225,
226,
230,
232,
233,
234,
235,
236,
]

onplayerentering:
function onPlayerEnteringVehicle(player, vehicle, seat)
{
if ( player.Vehicle.Model == bmodels )
{
if ( ReadIniBool("stats.ini","b",player.Name)) return true;
else {
MessagePlayer("[#ff0000]You need driver license B, sorry.",player)
return false;
}
}
}


i cant enter the vehicles, even if there is the bool true in stats.ini "b"

no errors prints in the console

.

Did you mean:
if ( player.Vehicle.Model in bmodels )Instead of:
if ( player.Vehicle.Model == bmodels )
?
.

Kewun


Thijn

Return true then. You're only doing a return false inside the if, but no true outside it.

Kewun


Kewun

still not works

function onPlayerEnteringVehicle(player, vehicle, seat)
{
   if ( player.Vehicle.Model in bmodels )
   {
      if ( ReadIniBool("stats.ini","b",player.Name)) return true;
      else {
         MessagePlayer("[#ff0000]You need driver license B, sorry.",player)
         return false;
      }
      return true;
   }
}

Thijn


Kewun

no, now i can enter any vehicle without driver license b :/

KAKAN

local p = ReadIniBool("stats.ini","b",player.Name);
print( p + " " + typeof p );
Try it and tell us the output of it.
oh no

Kewun

there isnt any prints in the console

function onPlayerEnteringVehicle(player, vehicle, seat)
{
if ( player.Vehicle.Model == bmodels )
{
if ( ReadIniBool("stats.ini","b",player.Name)) {
local p = ReadIniBool("stats.ini","b",player.Name);
print( p + " " + typeof p );
return true;
}
else {
local p = ReadIniBool("stats.ini","b",player.Name);
print( p + " " + typeof p );
MessagePlayer("[#ff0000]You need driver license B, sorry.",player)
return false;
}
}
return true;
}

KAKAN

lol man, use "in" keyword instead of ==.
That's your problem.
oh no

Kewun


Kewun

function onPlayerEnteringVehicle(player, vehicle, seat)
{
if ( player.Vehicle.Model in bmodels )
{
if ( ReadIniBool("stats.ini","b",player.Name)) {
local p = ReadIniBool("stats.ini","b",player.Name);
print( p + " " + typeof p );
return true;
}
else {
local p = ReadIniBool("stats.ini","b",player.Name);
print( p + " " + typeof p );
MessagePlayer("[#ff0000]You need driver license B, sorry.",player)
return false;
}
}
return true;
}


KAKAN

try this:-
function onPlayerEnteringVehicle(player, vehicle, seat)
{
  print("Callback received");
}
Check for duplicate functions too.
oh no

Kewun

yeah, it pritned to the console Callback received
no duplicates