Jump to content

[Help] Failed to create a vehicle


TheBull

Recommended Posts

Helloo Guys.

I've made a script to creat a rhino for vip players only but it's not working dont know why ,and when i spawn the vehicle i can't enter the vehicle,here are my codes :

Client :

function scriptCreateTank ( commandName ) 
      local luckyBugger = getLocalPlayer()  
      local x, y, z = getElementPosition ( luckyBugger )  
      createVehicle ( 432, x + 7, y, z + 2 )  
end 
  
addCommandHandler ( "tank", scriptCreateTank ) 
addEvent("creatTank", true ) 
addEventHandler("creatTank", getRootElement(), scriptCreateTank )  

Server :

function creatVehicleCommand ( playerSource, commandName ) 
    local acc = getPlayerAccount (playerSource) 
    if acc and not isGuestAccount(acc) then 
    local accName = getAccountName (acc ) 
     if isObjectInACLGroup ("user."..accName, aclGetGroup ( "VIP" ) ) then 
        local theTriggerer = getPlayerName ( playerSource ) 
        if commandName == "tank" then 
                triggerClientEvent (root,  "creatTank") 
            end 
        end 
    end 
end 
addCommandHandler ( "tank", creatVehicleCommand ) 

Link to comment

-- Server Side 
  
function creatVehicleCommand ( playerSource, commandName ) 
    local acc = getPlayerAccount (playerSource) 
    if acc and not isGuestAccount(acc) then 
    local accName = getAccountName (acc ) 
     if isObjectInACLGroup ("user."..accName, aclGetGroup ( "VIP" ) ) then 
    triggerClientEvent (playerSource,  "creatTank",playerSource) 
        end 
    end 
end 
addCommandHandler ( "tank", creatVehicleCommand ) 

-- Client Side 
  
addEvent("creatTank", true ) 
addEventHandler("creatTank", root, 
function (    ) 
      local x, y, z = getElementPosition ( localPlayer ) 
      if ( isElement ( vehicle ) ) then destroyElement ( vehicle ) 
      vehicle = nil 
      vehicle = createVehicle ( 432, x + 7, y, z + 2 )  
             end 
     end 
 ) 
Link to comment
-- Server Side 
  
function creatVehicleCommand ( playerSource, commandName ) 
    local acc = getPlayerAccount (playerSource) 
    if acc and not isGuestAccount(acc) then 
    local accName = getAccountName (acc ) 
     if isObjectInACLGroup ("user."..accName, aclGetGroup ( "VIP" ) ) then 
    triggerClientEvent (playerSource,  "creatTank",playerSource) 
        end 
    end 
end 
addCommandHandler ( "tank", creatVehicleCommand ) 

-- Client Side 
  
addEvent("creatTank", true ) 
addEventHandler("creatTank", root, 
function (    ) 
      local x, y, z = getElementPosition ( localPlayer ) 
      if ( isElement ( vehicle ) ) then destroyElement ( vehicle ) 
      vehicle = nil 
      vehicle = createVehicle ( 432, x + 7, y, z + 2 )  
             end 
     end 
 ) 

Not working.No errors appeared.

Link to comment

try this !

-- Server Side 
   
function creatVehicleCommand ( playerSource, commandName ) 
    local acc = getPlayerAccount (playerSource) 
    if acc and not isGuestAccount(acc) then 
    local accName = getAccountName (acc ) 
     if isObjectInACLGroup ("user."..accName, aclGetGroup ( "VIP" ) ) then 
    local x, y, z = getElementPosition ( playerSource ) 
     if ( isElement ( vehicle ) ) then destroyElement ( vehicle ) 
      vehicle = nil 
      vehicle = createVehicle ( 432, x + 7, y, z + 2 ) 
              end 
        end 
    end 
end 
addCommandHandler ( "tank", creatVehicleCommand ) 
Link to comment

Server:

veh = {} 
  
addCommandHandler("tank", 
function(player) 
    local account = getPlayerAccount(player) 
    if account and not isGuestAccount(account) then 
        local accountName = getAccountName(account) 
        if isObjectInACLGroup("user."..accountName, aclGetGroup("VIP")) then  
            if isElement(veh[player]) then 
                destroyElement(veh[player]) 
                veh[player] = nil 
            end 
            local x, y, z = getElementPosition(player) 
            veh[player] = createVehicle(432, x+7, y, z+2) 
        end 
    end 
end) 

Don't forget to remove the vehicle when explode or player quit from the server.

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