Jump to content

server.lua4:attempt to compare string with number


Adde

Recommended Posts

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) 

Link to comment
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) 

Link to comment

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) 

Link to comment

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...