Walkerzer4 Posted February 15, 2018 Share Posted February 15, 2018 Hello, I'm trying to put a level system that gives rewards every time the player spawn on my mta dayz server, but I'm having an error. I'm not getting the gun and it's giving that error. Error: Bad argument @ 'setElementData' [Expected element at argument 1, got number '1544.5' Client: function GiveItemOnSpawn () if getElementData(localPlayer, "level") == 1 then triggerServerEvent ("LEVEL1",localPlayer) end end Server: function GiveItemOnSpawn (player) setElementData(player, "M4A1 CCO", 1) outputChatBox("Test!", playersource, 255, 255, 255, true) end addEvent ("LEVEL1",true) addEventHandler ("LEVEL1",getRootElement(),GiveItemOnSpawn ) addEventHandler("onPlayerSpawn",getRootElement(), GiveItemOnSpawn) Thanks. Link to comment
Tekken Posted February 15, 2018 Share Posted February 15, 2018 function GiveItemOnSpawn () setElementData(source, "M4A1 CCO", 1) outputChatBox("Test!", playersource, 255, 255, 255, true) end addEvent ("LEVEL1",true) addEventHandler ("LEVEL1",getRootElement(),GiveItemOnSpawn ) addEventHandler("onPlayerSpawn",getRootElement(), GiveItemOnSpawn) Link to comment
Moderators IIYAMA Posted February 15, 2018 Moderators Share Posted February 15, 2018 function GiveItemOnSpawn () setElementData(source, "M4A1 CCO", 1) outputChatBox("Test!", source, 255, 255, 255, true) end addEvent ("LEVEL1",true) addEventHandler ("LEVEL1",getRootElement(),GiveItemOnSpawn ) addEventHandler("onPlayerSpawn",getRootElement(), GiveItemOnSpawn) https://wiki.multitheftauto.com/wiki/OnPlayerSpawn Source The source of this event is the player that just spawned. https://wiki.multitheftauto.com/wiki/AddEventHandler addEventHandler This function will add an event handler. An event handler is a function that will be called when the event it's attached to is triggered. See event system for more information on how the event system works. Event handlers are functions that are called when a particular event happens. Each event specifies a specific set of variables that are passed to the event handler and can be read by your function. The following global variables are available for use in handler functions: source: the element that triggered the event Link to comment
Walkerzer4 Posted February 15, 2018 Author Share Posted February 15, 2018 1 minute ago, Tekken said: function GiveItemOnSpawn () setElementData(source, "M4A1 CCO", 1) outputChatBox("Test!", playersource, 255, 255, 255, true) end addEvent ("LEVEL1",true) addEventHandler ("LEVEL1",getRootElement(),GiveItemOnSpawn ) addEventHandler("onPlayerSpawn",getRootElement(), GiveItemOnSpawn) The error does not happen, but the player does not receive the weapon. Link to comment
Walkerzer4 Posted February 15, 2018 Author Share Posted February 15, 2018 Solved, the problem was in my gamemode. Thanks for all. 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