Jump to content

server.lua4:attempt to compare string with number


Adde

Recommended Posts

Posted

Hey! Got a prob, I don´t understand what the debug means. Or I understand where the problem is but not how to solve it :/ anyone that can help me?

debug ( when entering the specified vehicle ) = server.lua4:attempt to compare string with number

the script:

vehicleSkins = {  [425]=true,  [520]=true,  [432]=true  } 
  
function onlyLevel15(thePlayer, seat, jacked) 
if ( getElementData(thePlayer, "Level") <= 16 ) then 
if ( vehicleSkins[getElementModel(source)] ) then 
removePedFromVehicle ( thePlayer ) 
outputChatBox("You need to be atleast level 15 to be able to use this vehicle",thePlayer, 255,0,0) 
end 
end 
end 
addEventHandler("onVehicleEnter", getRootElement(), 
 onlyLevel15) 

Posted
vehicleSkins = {  [425]=true,  [520]=true,  [432]=true  } 
  
function onlyLevel15(thePlayer, seat, jacked) 
if tonumber(getElementData(thePlayer, "Level") )  <= 16  then 
if ( vehicleSkins[getElementModel(source)] ) then 
removePedFromVehicle ( thePlayer ) 
outputChatBox("You need to be atleast level 15 to be able to use this vehicle",thePlayer, 255,0,0) 
end 
end 
end 
addEventHandler("onVehicleEnter", getRootElement(), 
 onlyLevel15) 

Posted

Thx it works, btw why wont cancelEvent() work instead of removePedFromVehicle? Nothing in debug.

I found the reason, i changed onVehicleEnter to onVehicleStartEnter.

vehicleSkins = {  [425]=true,  [520]=true,  [432]=true  } 
  
function onlyLevel15(thePlayer, seat, jacked) 
if tonumber(getElementData(thePlayer, "Level") )  <= 16  then 
if ( vehicleSkins[getElementModel(source)] ) then 
cancelEvent() 
outputChatBox("You need to be atleast level 15 to be able to use this vehicle",thePlayer, 255,0,0) 
end 
end 
end 
addEventHandler("onVehicleEnter", getRootElement(), 
onlyLevel15) 

  • Moderators
Posted

btw is your operator ok?

Because when you are level 17 it probably isn't going to working.

if tonumber(getElementData(thePlayer, "Level") or 0 )  >= 15  then 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...