xPawlo Posted December 7, 2017 Share Posted December 7, 2017 Why this is not working? function poliwasted() local player = getLocalPlayer() local team = getTeamFromName("Milicja") if isPlayerInTeam(player, team) then setElementModel ( player, 281 ) setPedArmor ( player, 100 ) setPlayerNametagColor ( player, 0, 8, 255 ) giveWeapon( player, 3, 1000 ) end end addEventHandler("onPlayerWasted", getRootElement(), poliwasted) <meta> <info author="xPawlo" version="0.1" type="script" name="frakcje" description="" /> <script src="frakcjeclient.lua" type="client" /> </meta> Link to comment
xPawlo Posted December 7, 2017 Author Share Posted December 7, 2017 (edited) In console i didn't see any errors, it says that resource started succesfully Edited December 7, 2017 by xPawlo Link to comment
pa3ck Posted December 7, 2017 Share Posted December 7, 2017 setPedArmor is server side only, you can't use it client side. Link to comment
kasya85 Posted December 7, 2017 Share Posted December 7, 2017 (edited) onPlayerWasted is server side event only, you can't use it client side. Edited December 7, 2017 by kasya85 Link to comment
Storm-Hanma Posted December 7, 2017 Share Posted December 7, 2017 (edited) Yea right u need to check first weather script works In client or server side ! Always use debug script 1-3 mode to check errors console don't output errors for all functions Edited December 7, 2017 by Khadeer143 Link to comment
xPawlo Posted December 8, 2017 Author Share Posted December 8, 2017 When I change to server side, the console says "attempt to call global 'getLocalPlayer' (a nil value)". Link to comment
Dimos7 Posted December 8, 2017 Share Posted December 8, 2017 yes because the getLocalPlayer is client side only function poliwasted() local team = getTeamFromName("Milicja") if isPlayerInTeam(source, team) then setElementModel(source, 281) setPedArmor(source, 100) setPlayerNametagColor(source, 0, 8, 255) giveWeapon(source, 3, 1000) end end addEventHandler("onPlayerWasted", root, poliwasted) Link to comment
xPawlo Posted December 8, 2017 Author Share Posted December 8, 2017 (edited) Still not working. Console says "attempt to call global 'isPlayerInTeam' (a nil value)" Edited December 8, 2017 by xPawlo Link to comment
King12 Posted December 8, 2017 Share Posted December 8, 2017 Add the useful function in your code then. function isPlayerInTeam(player, team) assert(isElement(player) and getElementType(player) == "player", "Bad argument 1 @ isPlayerInTeam [player expected, got " .. tostring(player) .. "]") assert((not team) or type(team) == "string" or (isElement(team) and getElementType(team) == "team"), "Bad argument 2 @ isPlayerInTeam [nil/string/team expected, got " .. tostring(team) .. "]") return getPlayerTeam(player) == (type(team) == "string" and getTeamFromName(team) or (type(team) == "userdata" and team or (getPlayerTeam(player) or true))) end Link to comment
xPawlo Posted December 8, 2017 Author Share Posted December 8, 2017 I repaired it. I changed "onPlayerWasted" to "onPlayerSpawn". Thanks guys 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