thegost Posted March 13, 2016 Share Posted March 13, 2016 Hello People I have one problema in my script HouseRobbery / Store Robberys , problema is i add in script bonne attake bag to players in end the Sr but he go warehouses the bag not remove players have bag all time can help Server function nextStep() for i, robber in pairs (getElementsWithinColShape(houserobCircle, "player")) do if not isPedDead(robber) and isPedOnGround(robber) and robberTeams[getTeamName(getPlayerTeam(robber))] then local x,y,z = getElementPosition(robber) exports.RPGcommands:giveMoney(robber, 16000) exports.RPGcommands:sendMessage("*STORE ROBBERY* You got $16000 from the rob, go to the a warehouse in the city to get more money!", 0, 255, 0, robber) atBag = createObject(1210,x,y,z) exports.bone_attach:attachElementToBone(atBag,robber,12,0,0.05,0.27,0,180,0) triggerClientEvent("showWarehouses", robber) end end Client [ PROBLEM IN] function finish(robber) if not isPedDead(robber) and isPedOnGround(robber) and robber == getLocalPlayer(robber) then exports.RPGcommands:giveMoney(robber, 10000) exports.RPGcommands:sendClientMessage("You got $10000 from the warehouse.", 0, 255, 0) hideALL() destroyElement(atBag) end end addEventHandler("onClientMarkerHit", marker, finish) Link to comment
ALw7sH Posted March 13, 2016 Share Posted March 13, 2016 Because atBag is undefined in client side you can make it an element data to the player Link to comment
KariiiM Posted March 13, 2016 Share Posted March 13, 2016 function finish(robber) if not isPedDead(robber) and isPedOnGround(robber) and robber == getLocalPlayer() then exports.RPGcommands:giveMoney(robber, 10000) exports.RPGcommands:sendClientMessage("You got $10000 from the warehouse.", 0, 255, 0) hideALL() if isElement(atBag) then destroyElement(atBag) atBag = nil end end end addEventHandler("onClientMarkerHit", marker, finish) Link to comment
ALw7sH Posted March 14, 2016 Share Posted March 14, 2016 function nextStep() for i, robber in pairs (getElementsWithinColShape(houserobCircle, "player")) do if not isPedDead(robber) and isPedOnGround(robber) and robberTeams[getTeamName(getPlayerTeam(robber))] then local x,y,z = getElementPosition(robber) exports.RPGcommands:giveMoney(robber, 16000) exports.RPGcommands:sendMessage("*STORE ROBBERY* You got $16000 from the rob, go to the a warehouse in the city to get more money!", 0, 255, 0, robber) local atBag = createObject(1210,x,y,z) setElementData(robber,"bag",atBag) exports.bone_attach:attachElementToBone(atBag,robber,12,0,0.05,0.27,0,180,0) triggerClientEvent("showWarehouses", robber) end end end function finish(robber) if not isPedDead(robber) and isPedOnGround(robber) and robber == getLocalPlayer(robber) then exports.RPGcommands:giveMoney(robber, 10000) exports.RPGcommands:sendClientMessage("You got $10000 from the warehouse.", 0, 255, 0) hideALL() local atBag = getElementData(robber,"bag") destroyElement(atBag) end end addEventHandler("onClientMarkerHit", marker, finish) Next time don't wait until someone do everything for you, I've already told you what's wrong with your code and what you have to do just try at least Link to comment
KariiiM Posted March 14, 2016 Share Posted March 14, 2016 Ah I didnt see the other side where you created the object.. Link to comment
thegost Posted March 14, 2016 Author Share Posted March 14, 2016 I already tried but I don't get and the suitcase continues in the hand doesn't leave Link to comment
KariiiM Posted March 14, 2016 Share Posted March 14, 2016 Help»? Sure, try this and tell me the result: --Server side: local atBag = {} function nextStep() for i, robber in pairs (getElementsWithinColShape(houserobCircle, "player")) do if not isPedDead(robber) and isPedOnGround(robber) and robberTeams[getTeamName(getPlayerTeam(robber))] then local x,y,z = getElementPosition(robber) exports.RPGcommands:giveMoney(robber, 16000) exports.RPGcommands:sendMessage("*STORE ROBBERY* You got $16000 from the rob, go to the a warehouse in the city to get more money!", 0, 255, 0, robber) atBag[robber] = createObject(1210,x,y,z) exports.bone_attach:attachElementToBone(atBag[robber],robber,12,0,0.05,0.27,0,180,0) triggerClientEvent("showWarehouses", robber) end end end addEvent("onRemoveTheBag",true) addEventHandler("onRemoveTheBag", getRootElement(), function (robber) if atBag[robber] and isElement(atBag[robber]) then destroyElement(atBag[robber]) atBag[robber] = nil end end) --Client side: function finish(robber) if not isPedDead(robber) and isPedOnGround(robber) and robber == getLocalPlayer() then exports.RPGcommands:giveMoney(robber, 10000) exports.RPGcommands:sendClientMessage("You got $10000 from the warehouse.", 0, 255, 0) hideALL() triggerServerEvent("onRemoveTheBag",robber,robber) end end addEventHandler("onClientMarkerHit", marker, finish) Link to comment
KariiiM Posted March 15, 2016 Share Posted March 15, 2016 thanks now work Glad to hear that, good luck 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