Notorious^ Posted November 14, 2018 Share Posted November 14, 2018 (edited) Hello all, I want give m4 to player when he first join.but my code not working.whats my mistake.can you help me ? Quote function joinPlayerGiveWeapon ( ) giveWeapon ( source, 31, 200 ) end addEventHandler ( "onPlayerJoin", root, joinPlayerGiveWeapon ) Edited November 14, 2018 by Notorious^ Link to comment
Fist Posted November 14, 2018 Share Posted November 14, 2018 (edited) Should be working, make sure this script is running on server side and als make sure in meta.xml file there's actually code of line that uses that file as server side script. Edited November 14, 2018 by Fist Link to comment
Notorious^ Posted November 14, 2018 Author Share Posted November 14, 2018 1 hour ago, Fist said: Should be working, make sure this script is running on server side and als make sure in meta.xml file there's actually code of line that uses that file as server side script. ı checked again now.all is good man.why not working ı dont know :C Link to comment
LyricalMM Posted November 14, 2018 Share Posted November 14, 2018 well if you want to give the player only for the first join, you can do this: setElementData(source, "hasRecieved", false) -- Do this on your first join script or register function joinPlayerGiveWeapon ( ) hasWeap = getElementData(source, "hasRecieved") if not hasWeap then giveWeapon ( source, 31, 200 ) setElementData(source, "hasRecieved", true) end end addEventHandler ( "onPlayerJoin", root, joinPlayerGiveWeapon ) Link to comment
Notorious^ Posted November 14, 2018 Author Share Posted November 14, 2018 all codes make senses.but not working.aaaaaaa! ı putting in server side.and meta is true! Link to comment
Notorious^ Posted November 14, 2018 Author Share Posted November 14, 2018 <meta> <script src="server.lua"/> </meta> ? Link to comment
Dimos7 Posted November 14, 2018 Share Posted November 14, 2018 <meta> <script src ="server.lua" type="server"/> </meta> Link to comment
Notorious^ Posted November 14, 2018 Author Share Posted November 14, 2018 1 hour ago, Dimos7 said: <meta> <script src ="server.lua" type="server"/> </meta> ı tried 3 times not working mate. Link to comment
Dimos7 Posted November 14, 2018 Share Posted November 14, 2018 (edited) 2 minutes ago, Notorious^ said: ı tried 3 times not working mate. wired you are sure have it in mtaa folder resource also trtied to restart the resource after change it? Edited November 14, 2018 by Dimos7 Link to comment
Notorious^ Posted November 14, 2018 Author Share Posted November 14, 2018 hey ı am not newbie just ı cant give first join weapon to player. https://files.fm/u/h6juyehx my resource with meta you can check :C Link to comment
N3xT Posted November 14, 2018 Share Posted November 14, 2018 3 hours ago, LyricalMM said: well if you want to give the player only for the first join, you can do this: setElementData(source, "hasRecieved", false) -- Do this on your first join script or register function joinPlayerGiveWeapon ( ) hasWeap = getElementData(source, "hasRecieved") if not hasWeap then giveWeapon ( source, 31, 200 ) setElementData(source, "hasRecieved", true) end end addEventHandler ( "onPlayerJoin", root, joinPlayerGiveWeapon ) Element data won't work correctly because when the player leaves the server the data will be gone, the only way to make it is by using accounts data or databases. 1 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