MGO Posted October 1, 2023 Share Posted October 1, 2023 Hi guys, I'm having trouble with the following code for my RP server the purpose of this is to take badge item from player and give key item instead but only in the area that I specified which is the flying zone, the whole script works fine except this part, I want it to exchange the badge for the key but if the player doesn't have the badge it will send a message saying you don't have any badges and if the exchange is made it will say you gave the badge so here's the code that I'm having trouble with : Client : bindKey( "E", "down", function() if getElementData(localPlayer, "Jobs") == "Dealer" then local detection = isElementWithinColShape ( localPlayer, Col ) if not( detection ) then return outputChatBox("#ffffff[ #FC861DFly-System#ffffff ] : You must be inside the flying zone.",255,255,255,true) end local nobadge = triggerServerEvent("NoBadge", localPlayer ) if not( nobadge ) then setPedAnimation(localPlayer, "BOMBER", "BOM_Plant", -1, false, false, false, false) triggerServerEvent("TakeBadgefromPlayer", localPlayer ) setTimer (function() local x, y, z = getElementPosition(localPlayer) local Object = createObject ( 677, x,y,z-1 ) outputChatBox("#ffffff[ #FC861DFly System#ffffff ] : You gave the badge.",255,255,255,true) setTimer(function(Object) if ( isElement(Object) ) then destroyElement(Object) triggerServerEvent("GivekeytoPlayer", localPlayer ) end end, 6000, 1,Object) end, 2000, 1) end end end ) Server : addEvent("TakeBadgefromPlayer", true) -- Give Badge. addEventHandler("TakeBadgefromPlayer", root, function() if exports.global:hasItem(client, 285) then exports.global:takeItem(client, 285) else outputChatBox("#ffffff[ #FC861DFly-System#ffffff ] : You don't have enough badges.",source,255, 255, 255,true) end end ) addEvent("GiveKeytoPlayer", true) -- Receive Key. addEventHandler("GiveKeytoPlayer", root, function() exports.global:giveItem(client, 33, 10) outputChatBox("#ffffff[ #FC861DFly-System#ffffff ] : You got 10 keys",source,255,255,255,true) end ) addEvent("Nobadge", true) -- Don't have Badge. addEventHandler("Nobadge", root, function() if not (exports.global:hasItem(client, 285))then outputChatBox("#ffffff[ #FC861DFly-System#ffffff ] : You don't have any badges.",source,255,255,255,true) end end ) Link to comment
Hydra Posted October 2, 2023 Share Posted October 2, 2023 First of all, Do not post 3 topics about the same problem. Post one topic about your issues and wait for someone to help you 1 Link to comment
MGO Posted October 2, 2023 Author Share Posted October 2, 2023 I couldn't figure out how to delete a post, I'm sorry Link to comment
Hydra Posted October 2, 2023 Share Posted October 2, 2023 (edited) Client: bindKey("e", "down", function() local getJob = getElementData(localPlayer, "Jobs") or "NONE" if getJob == "Dealer" then if not isElementWithinColShape(localPlayer, Col) then return outputChatBox("You must be inside the farming zone", 255, 255, 255, true) end if not exports.global:hasItem(localPlayer, 285) then return end if TSK == false then return end TSK = false setPedAnimation(localPlayer, "BOMBER", "BOM_Plant", -1, false, false, false, false) triggerServerEvent("TakeSeedfromPlayer", localPlayer) setTimer(function() local x, y, z = getElementPosition(localPlayer) local Object = createObject(677, x, y, z - 1) outputChatBox("You planted seed", 255, 255, 255, true) TSK = true setTimer(function() if isElement(Object) then destroyElement(Object) triggerServerEvent("GiveDrugtoPlayer", localPlayer) end end, 6000, 1) end, 2000, 1) end end) Server: addEvent("TakeSeedfromPlayer", true) addEventHandler("TakeSeedfromPlayer", root, function(takeseed) if exports.global:hasItem(source, 285) then exports.global:takeItem(source, 285) else outputChatBox("#ffffff[ #FC861DDrug-System#ffffff ] : You don't have enough seeds.",source,255, 255, 255,true) end end) The problem was solved on discord, so I think this topic can be closed Edited October 2, 2023 by Hydra 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