Benevolence Posted September 8, 2011 Share 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' Link to comment
Castillo Posted September 8, 2011 Share 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 Link to comment
Benevolence Posted September 9, 2011 Author Share 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) Link to comment
Castillo Posted September 9, 2011 Share Posted September 9, 2011 You have an extra ")" in line 2, remove it. Link to comment
Benevolence Posted September 9, 2011 Author Share Posted September 9, 2011 You have an extra ")" in line 2, remove it. No, when I remove it, it says I need one. Link to comment
Castillo Posted September 9, 2011 Share 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? Link to comment
BinSlayer1 Posted September 9, 2011 Share 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? Link to comment
SDK Posted September 9, 2011 Share Posted September 9, 2011 1337 scripting technique Is it working now? Link to comment
Cadu12 Posted September 9, 2011 Share 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 Link to comment
Castillo Posted September 9, 2011 Share Posted September 9, 2011 Yes, but after you said that, I fixed the error, then he got confused I guess. Link to comment
Benevolence Posted September 9, 2011 Author Share 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. 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