villr Posted June 21, 2011 Share Posted June 21, 2011 Got a problem with my godmode script.. Part of server bit: function staff ( source, commandName) if isPlayerAdmin(source) then setPlayerTeam" class="kw6">setPlayerTeam" class="kw6">setPlayerTeam ( source, teamStaff ) setPlayerWantedLevel ( source, 0 ) takeAllWeapons ( source ) giveWeapon ( source, 3, 1 ) giveWeapon ( source, 17, 500 ) giveWeapon ( source, 22, 700 ) giveWeapon ( source, 24, 100 ) giveWeapon (source, 27, 1000 ) giveWeapon (source, 29, 1900 ) giveWeapon (source, 31, 1500 ) giveWeapon ( source, 34, 1500 ) giveWeapon ( source, 39, 500 ) giveWeapon ( source, 40, 5 ) triggerClientEvent(source,"god_mode",source) setElementHealth ( source, 1000 ) setPlayerNametagColor ( source, 190, 200, 190 ) setElementModel ( source, 165 ) setPedArmor ( source, 1000 ) else outputChatBox ( "*" .. getPlayerName ( source ) .. "* this command is only for Staff .", source , 255,0,0 ) end end addCommandHandler("staff", staff) Client: addEvent("god_mode",true) addEventHandler("god_mode",getRootElement(), function () addEventHandler ( "onClientPlayerDamage", getRootElement(), cancelEventEvent) end) Whats the problem with it?.. this is the error message:server triggered clientisde event god_mode, but event is not added clientside Link to comment
Castillo Posted June 21, 2011 Share Posted June 21, 2011 function staff ( thePlayer, commandName) if isPlayerAdmin(thePlayer) then setPlayerTeam ( thePlayer, teamStaff ) setPlayerWantedLevel ( thePlayer, 0 ) takeAllWeapons ( thePlayer ) giveWeapon ( thePlayer, 3, 1 ) giveWeapon ( thePlayer, 17, 500 ) giveWeapon ( thePlayer, 22, 700 ) giveWeapon ( thePlayer, 24, 100 ) giveWeapon ( thePlayer, 27, 1000 ) giveWeapon ( thePlayer, 29, 1900 ) giveWeapon ( thePlayer, 31, 1500 ) giveWeapon ( thePlayer, 34, 1500 ) giveWeapon ( thePlayer, 39, 500 ) giveWeapon ( thePlayer, 40, 5 ) setElementHealth ( thePlayer, 1000 ) setPlayerNametagColor ( thePlayer, 190, 200, 190 ) setElementModel ( thePlayer, 165 ) setPedArmor ( thePlayer, 1000 ) triggerClientEvent(thePlayer,"god_mode",thePlayer) else outputChatBox ( "*" .. getPlayerName ( source ) .. "* this command is only for Staff .", thePlayer , 255,0,0 ) end end addCommandHandler("staff", staff) P.S: Check your meta.xml and make sure client it's really a client side. Link to comment
villr Posted June 21, 2011 Author Share Posted June 21, 2011 i have just moved this script from another scritp i had but i dunno if i forgot some parts but i dont think so but it dont work at all now when i changed beacuse that you posted dident help me .. and the script is clientside dunno how it dident got this is error: WARNING: villrpg/rpg_c.lua:4 Bad argument @'addEventHandler' Link to comment
Castillo Posted June 21, 2011 Share Posted June 21, 2011 (edited) You got a function missing, try using this instead: addEvent("god_mode",true) addEventHandler("god_mode",getRootElement(), function () addEventHandler ( "onClientPlayerDamage", getRootElement(), cancelEvent) end) Edited June 21, 2011 by Guest Link to comment
villr Posted June 21, 2011 Author Share Posted June 21, 2011 Still dont work Same error Link to comment
Kenix Posted June 21, 2011 Share Posted June 21, 2011 (edited) Try this addEvent("god_mode",true) addEventHandler("god_mode",getRootElement(), function () addEventHandler ( "onClientPlayerDamage", getLocalPlayer(),function() cancelEvent() end) end) Edited June 21, 2011 by Guest Link to comment
Castillo Posted June 21, 2011 Share Posted June 21, 2011 Villr, copy my code again, now it doesn't give anymore a bad argument. Link to comment
villr Posted June 21, 2011 Author Share Posted June 21, 2011 Thank you castillo soo mutch ) Link to comment
rafull6 Posted June 27, 2011 Share Posted June 27, 2011 won't work ERROR: god\gods.lua:2: attempt to call global 'isPlayerAdmin' (a nil value) Link to comment
JR10 Posted June 27, 2011 Share Posted June 27, 2011 He made the function "isPlayerAdmin" you have to remove it and put your admin check. Link to comment
rafull6 Posted June 27, 2011 Share Posted June 27, 2011 He made the function "isPlayerAdmin" you have to remove it and put your admin check. stupid question but how to make an admin check? (duno in lua) Link to comment
JR10 Posted June 27, 2011 Share Posted June 27, 2011 isObjectInACLGroup hasObjectPermissionTo Link to comment
rafull6 Posted June 27, 2011 Share Posted June 27, 2011 I've fixed that script but now have an error after i use "staff" command: Error: [2011-06-27 16:08:01] Starting god [2011-06-27 16:08:01] god restarted successfully [2011-06-27 16:08:10] ERROR: god\gods.lua:3: attempt to concatenate global 'playerName' (a nil value) My code: function staff ( thePlayer, commandName) local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) if isObjectInACLGroup ( "user." .. playerName, aclGetGroup ( "Admin" ) ) then setElementHealth ( thePlayer, 1000 ) setPlayerNametagColor ( thePlayer, 190, 200, 190 ) setElementModel ( thePlayer, 165 ) setPedArmor ( thePlayer, 1000 ) triggerClientEvent(thePlayer,"god_mode",thePlayer) else outputChatBox ( "*" .. getPlayerName ( source ) .. "* this command is only for Staff .", thePlayer , 255,0,0 ) end end addCommandHandler("staff", staff) Link to comment
Kenix Posted June 27, 2011 Share Posted June 27, 2011 try: function staff ( thePlayer, commandName) local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) if isObjectInACLGroup ( "user." .. accName, aclGetGroup ( "Admin" ) ) then setElementHealth ( thePlayer, 1000 ) setPlayerNametagColor ( thePlayer, 190, 200, 190 ) setElementModel ( thePlayer, 165 ) setPedArmor ( thePlayer, 1000 ) triggerClientEvent(thePlayer,"god_mode",thePlayer) else outputChatBox ( "*" .. getPlayerName ( source ) .. "* this command is only for Staff .", thePlayer , 255,0,0 ) end end addCommandHandler("staff", staff) Link to comment
rafull6 Posted June 27, 2011 Share Posted June 27, 2011 Thank you volk. that's works greate! 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