Jump to content

Problem with godmode...


villr

Recommended Posts

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

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

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 :S

this is error:

WARNING: villrpg/rpg_c.lua:4 Bad argument @'addEventHandler'

Link to comment

You got a function missing, try using this instead:

addEvent("god_mode",true) 
addEventHandler("god_mode",getRootElement(), 
function () 
addEventHandler ( "onClientPlayerDamage", getRootElement(), cancelEvent) 
end) 

Edited by Guest
Link to comment

Try this

addEvent("god_mode",true) 
addEventHandler("god_mode",getRootElement(), 
function () 
addEventHandler ( "onClientPlayerDamage", getLocalPlayer(),function() cancelEvent()  end)   
end) 

Edited by Guest
Link to comment

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...