Vehicle License Problem

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

Previous topic - Next topic

KAKAN

Quote from: Kewun on Aug 11, 2016, 08:51 AMyeah, it pritned to the console Callback received
no duplicates
try this:-
function onPlayerEnteringVehicle(player, vehicle, seat)
{
  print( typeof player.Vehicle.Model );
  print( player.Vehicle.Model in bmodels );
}
oh no

Kewun


Kewun

[SCRIPT]  integer
[SCRIPT]  false

Thijn

Quote from: Kewun on Aug 11, 2016, 04:57 PM[SCRIPT]  integer
[SCRIPT]  false

So, there's your answer. Now go fix it yourself.

Kewun

lol wut i dont understand

Xmair

It means that the vehicle's model is not in "bmodels".

Credits to Boystang!

VU Full Member | VCDC 6 Coordinator & Scripter | EG A/D Contributor | Developer of VCCNR | Developer of KTB | Ex-Scripter of EAD

Kewun

there is, 205 sabre, 205 in the bmodels. i entered sabre.

Stormeus

You can't do in lookups on an array, it can only check if an index is in a table.

You need to do bmodels.find(player.Vehicle.Model) != null instead. Note that this is a lazy solution and can be optimized.

Kewun

now i cant enter any vehicle even w/ license.. :/

function onPlayerEnteringVehicle(player, vehicle, seat)
{
if ( bmodels.find(playre.Vehicle.Model) != null )
{
if ( ReadIniBool ( "stats.ini","b",player.Name)) return true;
else return false;
}
return true;
}

correct this for me :/

Thijn

Its player, not playre

Also, if you play to actually develop a server you definitely need to learn from your mistake. Try to debug it yourself.
If you expect an if to succeed and it doesn't, try printing your statement information. It might not be what you think it contains.

.

.

Kewun

crap.. playre.. thats what happens when im sleepy. thx

Kewun

with player, i can now enter vehicles even with license

aight, ill try to fix it my self.

Kewun

hell yeah fixed it my self finally
function onPlayerEnteringVehicle(player, vehicle, seat)
{
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];
if ( bmodels.find(player.Vehicle.Model) )
{
if ( ReadIniBool ( "stats.ini","b",player.Name)) {
MessagePlayer("[#ffffff]License Check: True",player)
return true;
}
else {
MessagePlayer("[#ffffff]License Check: False",player)
return false;
}
}
}

thx all especially thijn :v

KAKAN

Quote from: Thijn on Aug 11, 2016, 08:16 PMIts player, not playre
in that case, squirrel should throw errors :/
oh no