Guest Posted July 14, 2018 Posted July 14, 2018 No errors no warning in debugscript I wan't only vips can spawn hydra by typing /cv 520 or /cv Hydra function onPlayerCommand ( cmd, thePlayer ) local p = {getElementPosition(source)} for _,vehicle in ipairs(getElementsByType("vehicle")) do if getElementModel(vehicle) == 520 then local v = {getElementPosition(vehicle)} if getDistanceBetweenPoints3D(p[1], p[2], p[3], v[1], v[2], v[3]) < 10 then destroyElement(vehicle) local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) if not isObjectInACLGroup ("user."..accName, aclGetGroup ( "VIP" ) ) then outputChatBox ( "● You must be VIP to spawn this vehicle", thePlayer, 255, 0, 0 ) end end end end end addEventHandler("onPlayerCommand", root, onPlayerCommand)
DiGiTal Posted July 14, 2018 Posted July 14, 2018 (edited) function onPlayerCommand(thePlayer, command, vehicleModel) local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) if not isObjectInACLGroup ("user."..accName, aclGetGroup ( "VIP" ) ) then if (tonumber(vehicleModel) == 520) then return outputChatBox ( "● You must be VIP to spawn this vehicle", thePlayer, 255, 0, 0 ) end local x,y,z = getElementPosition(thePlayer) x = x + 5 local createdVehicle = createVehicle(tonumber(vehicleModel),x,y,z) outputChatBox("●"..getVehicleName(createdVehicle).."Has been spawned",thePlayer, 255, 0, 0 ) end addCommandHandler("cv", onPlayerCommand) @Scarfas Edited July 14, 2018 by DiGiTal
Guest Posted July 14, 2018 Posted July 14, 2018 (edited) But you did not write this addEventHandler("onPlayerCommand", root, onPlayerCommand) ? just asking i wan't to learn ========== and what is wrong with my code? and thanks you Edited July 14, 2018 by Guest
DiGiTal Posted July 14, 2018 Posted July 14, 2018 of course i forgot to add a handler function onPlayerCommand(thePlayer, command, vehicleModel) local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) if not isObjectInACLGroup ("user."..accName, aclGetGroup ( "VIP" ) ) then if (tonumber(vehicleModel) == 520) then return outputChatBox ( "● You must be VIP to spawn this vehicle", thePlayer, 255, 0, 0 ) end local x,y,z = getElementPosition(thePlayer) x = x + 5 local createdVehicle = createVehicle(tonumber(vehicleModel),x,y,z) outputChatBox("●"..getVehicleName(createdVehicle).."Has been spawned",thePlayer, 255, 0, 0 ) end addCommandHandler("cv", onPlayerCommand) add Command , it's an handler by a command, means when player do command (ex:/greet) it handle a function ( here it's onPlayerCommand)
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