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' Can other people connect to your server? Use this tool to check: http://nightly.mtasa.com/ports/ Formerly known as Tank07.
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 San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
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) Can other people connect to your server? Use this tool to check: http://nightly.mtasa.com/ports/ Formerly known as Tank07.
Castillo Posted September 9, 2011 Posted September 9, 2011 You have an extra ")" in line 2, remove it. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
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. Can other people connect to your server? Use this tool to check: http://nightly.mtasa.com/ports/ Formerly known as Tank07.
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? San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
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?
SDK Posted September 9, 2011 Posted September 9, 2011 1337 scripting technique Is it working now? Learn Lua - Learn to script - GUI scripting Scripter tools - Find/fix errors yourself(!) Don't pm me for scripting help, keep it for the Scripting subforum!
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 Ingame nick: Cadu12
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. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
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. Can other people connect to your server? Use this tool to check: http://nightly.mtasa.com/ports/ Formerly known as Tank07.
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