viniciusMS Posted February 27, 2017 Share Posted February 27, 2017 Hello I'm using a level system. When level up the player gains items. But when dying, instead of the items disappearing from the inventory, the items continue. What is wrong with Script? And I would also like for an OutputChatbox as soon as I level up. Can anybody help me ... Cliente: function System () if getElementData(getLocalPlayer(),"level") == 2 then setElementData(localPlayer,"Winchester 1866", 1) setElementData(localPlayer,"7Rnd. 1866 Slugs", 14) elseif getElementData(getLocalPlayer(),"level") == 3 then setElementData(localPlayer,"Sawn-Off Shotgun", 1) setElementData(localPlayer,"2Rnd. Slug", 14) end end setTimer(System,100,0) Link to comment
Fist Posted February 27, 2017 Share Posted February 27, 2017 (edited) There is everything fine about your script. There could be something wrong with your gamemode instead but if you want to add ouputchatbox to everyone to see you'll have to do it through server side, you can just trigger server side pre-made function for this specific script that would output chat to everyone. Also i don't understand, why do you use setTimer instead of addEventHandler? function System () if getElementData(getLocalPlayer(),"level") == 2 then setElementData(localPlayer,"Winchester 1866", 1) setElementData(localPlayer,"7Rnd. 1866 Slugs", 14) triggerServerEvent("levelUpAnnouncement",resourceRoot,getElementData(localPlayer,"level")) elseif getElementData(getLocalPlayer(),"level") == 3 then setElementData(localPlayer,"Sawn-Off Shotgun", 1) setElementData(localPlayer,"2Rnd. Slug", 14) triggerServerEvent("levelUpAnnouncement",resourceRoot,getElementData(localPlayer,"level")) end end setTimer(System,100,0) -- THIS IS SERVER SIDE function levelUpAnnouncement(level) outputChatBox("Player "..source.." is level "..tostring(level).." now.",root) end addEvent("levelUpAnnouncement",true) addEventHandler("levelUpAnnouncement",resourceRoot,levelUpAnnouncement) Edited February 27, 2017 by Fist Link to comment
viniciusMS Posted February 27, 2017 Author Share Posted February 27, 2017 3 hours ago, viniciusMS said: Hello I'm using a level system. When level up the player gains items. But when dying, instead of the items disappearing from the inventory, the items continue. What is wrong with Script? And I would also like for an OutputChatbox as soon as I level up. Can anybody help me ... Cliente: function System () if getElementData(getLocalPlayer(),"level") == 2 then setElementData(localPlayer,"Winchester 1866", 1) setElementData(localPlayer,"7Rnd. 1866 Slugs", 14) elseif getElementData(getLocalPlayer(),"level") == 3 then setElementData(localPlayer,"Sawn-Off Shotgun", 1) setElementData(localPlayer,"2Rnd. Slug", 14) end end setTimer(System,100,0) Did not work. 2 hours ago, Fist said: There is everything fine about your script. There could be something wrong with your gamemode instead but if you want to add ouputchatbox to everyone to see you'll have to do it through server side, you can just trigger server side pre-made function for this specific script that would output chat to everyone. Also i don't understand, why do you use setTimer instead of addEventHandler? function System () if getElementData(getLocalPlayer(),"level") == 2 then setElementData(localPlayer,"Winchester 1866", 1) setElementData(localPlayer,"7Rnd. 1866 Slugs", 14) triggerServerEvent("levelUpAnnouncement",resourceRoot,getElementData(localPlayer,"level")) elseif getElementData(getLocalPlayer(),"level") == 3 then setElementData(localPlayer,"Sawn-Off Shotgun", 1) setElementData(localPlayer,"2Rnd. Slug", 14) triggerServerEvent("levelUpAnnouncement",resourceRoot,getElementData(localPlayer,"level")) end end setTimer(System,100,0) -- THIS IS SERVER SIDE function levelUpAnnouncement(level) outputChatBox("Player "..source.." is level "..tostring(level).." now.",root) end addEvent("levelUpAnnouncement",true) addEventHandler("levelUpAnnouncement",resourceRoot,levelUpAnnouncement) Did not work. 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