Benevolence Posted September 8, 2011 Posted September 8, 2011 So this gravity gun script has a toggle script. I want to add the check if player is admin in the script itself and not permissions in acl, just to make it easier and shiz. function toggleGGun(player) if (exports.global:isPlayerAdmin(sourcePlayer) then if not (sourcePlayer) then outputChatBox("You don't have permission to use this command.", thePlayer, 255, 194, 14) else local on = not exports.gravity_gun:isGravityGunEnabled(player) exports.gravity_gun:togglePlayerGravityGun(player,on) outputChatBox("gravity gun "..(on and "on" or "off"),player) addCommandHandler("ggun",toggleGGun) else addCommandHandler("ggun",toggleGGun) end I've failed. Gives an error like expected to close 'if' near 'else'
Castillo Posted September 8, 2011 Posted September 8, 2011 (edited) function toggleGGun(player) if exports.global:isPlayerAdmin(player) then local on = not exports.gravity_gun:isGravityGunEnabled(player) exports.gravity_gun:togglePlayerGravityGun(player,on) outputChatBox("gravity gun "..(on and "on" or "off"),player) else outputChatBox("You don't have permission to use this command.", player, 255, 194, 14) end end addCommandHandler("ggun",toggleGGun) Try with that. Edited September 8, 2011 by Guest
Benevolence Posted September 9, 2011 Author Posted September 9, 2011 This is retarded, it was working fine then randomly after I edited the text on chat like ggun is on, etc, it stopped working. I un-did it, etc and shiz now its giving me same thing. On line 2 'then' expected near ')' But I already added )? function toggleGGun(player) if exports.global:isPlayerAdmin(player)) then local on = not exports.gravitygun:isGravityGunEnabled(player) exports.gravitygun:togglePlayerGravityGun(player,on) outputChatBox("Gravity gun has been "..(on and "enabled." or "disabled."),player) else outputChatBox("You don't have permission to use this command.", player, 255, 194, 14) end end addCommandHandler("ggun",toggleGGun)
Castillo Posted September 9, 2011 Posted September 9, 2011 You have an extra ")" in line 2, remove it.
Benevolence Posted September 9, 2011 Author Posted September 9, 2011 You have an extra ")" in line 2, remove it. No, when I remove it, it says I need one.
Castillo Posted September 9, 2011 Posted September 9, 2011 Who's asking for help? you or me? if you remove it, it won't make any error. P.S: I'm sure you added the ")" because Cadu12 said so, right?
BinSlayer1 Posted September 9, 2011 Posted September 9, 2011 function toggleGGun(player) if exports.global:isPlayerAdmin(player) then local on = not exports.gravitygun:isGravityGunEnabled(player) exports.gravitygun:togglePlayerGravityGun(player,on) if on then outputChatBox("Gravity gun has been enabled",player) else outputChatBox("Gravity gun has been disabled",player) end else outputChatBox("You don't have permission to use this command.", player, 255, 194, 14) end end addCommandHandler("ggun",toggleGGun) try this btw wtf was that outputChatBox in line 8.. or is it some 1337 scripting technique?
Cadu12 Posted September 9, 2011 Posted September 9, 2011 function toggleGGun(player) if (exports.global:isPlayerAdmin(sourcePlayer) then if not (sourcePlayer) then outputChatBox("You don't have permission to use this command.", thePlayer, 255, 194, 14) else local on = not exports.gravity_gun:isGravityGunEnabled(player) exports.gravity_gun:togglePlayerGravityGun(player,on) outputChatBox("gravity gun "..(on and "on" or "off"),player) addCommandHandler("ggun",toggleGGun) else addCommandHandler("ggun",toggleGGun) end I didnt said that, only i said you missed ")". Look at line 2. Quote is from 1 st
Castillo Posted September 9, 2011 Posted September 9, 2011 Yes, but after you said that, I fixed the error, then he got confused I guess.
Benevolence Posted September 9, 2011 Author Posted September 9, 2011 function toggleGGun(player) if exports.global:isPlayerAdmin(player) then local on = not exports.gravitygun:isGravityGunEnabled(player) exports.gravitygun:togglePlayerGravityGun(player,on) if on then outputChatBox("Gravity gun has been enabled",player) else outputChatBox("Gravity gun has been disabled",player) end else outputChatBox("You don't have permission to use this command.", player, 255, 194, 14) end end addCommandHandler("ggun",toggleGGun) try this btw wtf was that outputChatBox in line 8.. or is it some 1337 scripting technique? It works, thank you.
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