TheBull Posted August 28, 2015 Share Posted August 28, 2015 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
iMr.SFA7 Posted August 28, 2015 Share Posted August 28, 2015 -- 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
pa3ck Posted August 28, 2015 Share Posted August 28, 2015 Vehicles created client-side are useless. You cant enter them, change colour etc. You must create them server-side in order to use them. Link to comment
TheBull Posted August 28, 2015 Author Share Posted August 28, 2015 -- 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
iMr.SFA7 Posted August 28, 2015 Share Posted August 28, 2015 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
TheBull Posted August 29, 2015 Author Share Posted August 29, 2015 Still not working,no errors tho. Link to comment
TAPL Posted August 29, 2015 Share Posted August 29, 2015 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
TheBull Posted August 29, 2015 Author Share Posted August 29, 2015 Thanks alot,it's working. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now