Jump to content

Help with a script


Benevolence

Recommended Posts

Posted

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'

Posted (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 by Guest
Posted

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) 

Posted
    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?

Posted
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

Posted
    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.

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...