Jump to content

Vehicle locked for class Help?


Bean666

Recommended Posts

hi guys . please help i have class as Admin but it wont work. i still cant enter the locked vehicle even i have the class as Admin. any help? and all vehicles shows the msg.

function cars () 
        c1 = createVehicle ( 520, -2891.84765625, 460.4560546875, 4.9140625, 0, 0, 90 ) 
    end 
      
    addEventHandler ( "onResourceStart", resourceRoot, cars ) 
      
    function onEnter(thePlayer) 
        if getElementData(source, "class") ~= "Admin" then 
            cancelEvent() 
            outputChatBox("This Vehicle Is Locked for the Class:Admin", thePlayer, 0, 255, 0) 
        end 
    end 
      
    addEventHandler("onVehicleStartEnter", getRootElement(), onEnter) 

Edited by Guest
Link to comment
function cars () 
        c1 = createVehicle ( 520, -2891.84765625, 460.4560546875, 4.9140625, 0, 0, 90 ) 
    end 
      
    addEventHandler ( "onResourceStart", resourceRoot, cars ) 
      
    function onEnter(thePlayer) 
        if getElementData(thePlayer, "class") ~= "Admin" then 
            cancelEvent() 
            outputChatBox("This Vehicle Is Locked for the Class:Admin", thePlayer, 0, 255, 0) 
        end 
    end 
      
    addEventHandler("onVehicleStartEnter", getRootElement(), onEnter) 

Link to comment
  
        c1 = createVehicle ( 520, -2891.84765625, 460.4560546875, 4.9140625, 0, 0, 90 ) 
  
  
function onEnter(thePlayer) 
        if getElementModel(source) == 520 and getElementData(thePlayer, "class") ~= "Admin" then 
            cancelEvent() 
            outputChatBox("This Vehicle Is Locked for the Class:Admin", thePlayer, 0, 255, 0) 
        end 
    end 
      
    addEventHandler("onVehicleStartEnter", getRootElement, onEnter) 

EDIT:

function data (plr) 
        if getElementData(plr, "class") ~="Admin" then 
        setElementData(plr, "class", "Admin") 
        outputChatBox("Your class data is: "..getElementData(plr, "class"), plr) 
    else 
        setElementData(plr, "class", "Nope") 
        outputChatBox("Your class data is: "..getElementData(plr, "class"), plr) 
    end 
end 
    addCommandHandler("class", data) 

Use this function to add/remove you and check your data so you can be sure whether your data is "Admin" or whatever.

Edited by Guest
Link to comment

Check the code again. You wouldn't have to use a function for creating a vehicle in this resource. The second code (EDIT one) is a function that removes/adds and shows the data, and I guess you've just copied that code which is why the vehicle wasn't created.

Edited by Guest
Link to comment

There was ')' missing in the code in the line 13.

function cars () 
        c1 = createVehicle ( 520, -2891.84765625, 460.4560546875, 4.9140625, 0, 0, 90 ) 
    end 
addEventHandler("onResourceStart", root, cars)  
  
function onEnter(thePlayer) 
        if getElementModel(source) == 520 and getElementData(thePlayer, "class") ~= "Admin" then 
            cancelEvent() 
            outputChatBox("This Vehicle Is Locked for the Class:Admin", thePlayer, 0, 255, 0) 
        end 
    end 
      
    addEventHandler("onVehicleStartEnter", getRootElement(Sr)) 

Link to comment

Try this

function cars () 
    c1 = createVehicle ( 520, -2891.84765625, 460.4560546875, 4.9140625, 0, 0, 90 ) 
    addEventHandler("onVehicleStartEnter", c1, onEnter) 
end 
addEventHandler ( "onResourceStart", resourceRoot, cars ) 
      
function onEnter(thePlayer) 
    if not isPlayerAdmin(thePlayer) then 
        outputChatBox("This Vehicle Is Locked for the Class:Admin", thePlayer, 0, 255, 0) 
        cancelEvent()      
    end 
end 
      
     
function isPlayerAdmin(plr) 
    if not isElement(plr) then return end  
        if (getElementData(plr,"class") == "Admin") then  
        return true 
    else 
        return false 
    end  
end  

Link to comment
function cars () 
    c1 = createVehicle ( 520, -2891.84765625, 460.4560546875, 4.9140625, 0, 0, 90 ) 
end 
addEventHandler ( "onResourceStart", resourceRoot, cars ) 
  
function onEnter(thePlayer) 
    if getElementModel(thePlayer) == 520 and getElementData(thePlayer, "class") ~= "Admin" then 
        outputChatBox("This Vehicle Is Locked for the Class:Admin", thePlayer, 0, 255, 0) 
        cancelEvent() 
    end 
end 
addEventHandler("onVehicleStartEnter", root, onEnter) 

Link to comment
when i'm in admin class , it is still locked.

bro try this and tell me what you can see in chatbox.

function checkClass(player) 
    if not isElement(player) then return end  
      local class = getElementData(player,"class") 
       if class then  
         outputChatBox("You current calss is : "..class,player,255,0,0) 
      end  
end  
addCommandHandler("class",checkClass) 

Link to comment
function cars () 
    c1 = createVehicle ( 520, -2891.84765625, 460.4560546875, 4.9140625, 0, 0, 90 ) 
end 
addEventHandler ( "onResourceStart", resourceRoot, cars ) 
  
function onEnter(thePlayer) 
    if getElementModel(thePlayer) == 520 and getElementData(thePlayer, "class") ~= "Admin" then 
        outputChatBox("This Vehicle Is Locked for the Class:Admin", thePlayer, 0, 255, 0) 
        cancelEvent() 
    end 
end 
addEventHandler("onVehicleStartEnter", root, onEnter) 

anyone can ride it.

Link to comment
@Walid it shows Squads , but in TAB , my team is squads... and my class is Alpha Team

Try this type T/admin in chatBox then try to enter the vehicle

  
function cars () 
    c1 = createVehicle ( 520, -2891.84765625, 460.4560546875, 4.9140625, 0, 0, 90 ) 
    addEventHandler("onVehicleStartEnter", c1, onEnter) 
end 
addEventHandler ( "onResourceStart", resourceRoot, cars ) 
      
function onEnter(thePlayer) 
    if not isPlayerAdmin(thePlayer) then 
        outputChatBox("This Vehicle Is Locked for the Class:Admin", thePlayer, 0, 255, 0) 
        cancelEvent()     
    end 
end 
      
function isPlayerAdmin(plr) 
    if not isElement(plr) then return end 
        if (getElementData(plr,"class") == "Admin") then 
        return true 
    else 
        return false 
    end 
end 
  

Edited by Guest
Link to comment
wait.

edit:

doesnt work.

Try this i already tried it it's working fine without typing t/admin

function cars () 
    c1 = createVehicle ( 520, -2891.84765625, 460.4560546875, 4.9140625, 0, 0, 90 ) 
    addEventHandler("onVehicleStartEnter", c1, onEnter) 
end 
addEventHandler ( "onResourceStart", resourceRoot, cars ) 
      
function onEnter(thePlayer) 
    if not isPlayerAdmin(thePlayer) then 
        outputChatBox("This Vehicle Is Locked for the Class:Admin", thePlayer, 0, 255, 0) 
        cancelEvent()     
    end 
end 
      
function isPlayerAdmin(plr) 
    if not isElement(plr) then return end 
        if (getElementData(plr,"class") == "Admin") then 
        return true 
    else 
        return false 
    end 
end 
  
function setMyClassTo (player) 
  if not isElement(player) then return end 
     local class = "Admin" 
       setElementData(player,"class",tostring(class)) 
end 
addCommandHandler("admin",setMyClassTo) 

Note: your class must be different to Admin

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