Jump to content

Making a command admin only + godmode command?


Azortharion

Recommended Posts

So basically I just installed the bbullets resource (exploding bullets), and I want to make it admin-only.

I am a -COMPLETE IDIOT-, so please treat me as such when you explain, what I have tried so far:

- adding "command.bbullets" to the admin ACL rights.

- adding "resource.blowing_bullets" to the admin ACL

Have found some scripts that I put into the resource's code, but well. I am doing it completely wrong.

Original code, server.lua

function bulletexplosion (hitX, hitY, hitZ) 
    createExplosion ( hitX, hitY, hitZ, 2 ) 
end 
  
addEventHandler("bulletboom",getRootElement(),bulletexplosion) 
end 
  

I added the following piece of code to the top of that script, as in this piece:

{ 
  if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFF0000AA, "This command can only be used by an admin!!"); 

-

I added the same piece of code to the top of the client.lua script.

The server.lua script:

bBullets = false 
  
function enableBlowingbullets() 
    if (bBullets == false)then 
    bBullets = true 
    outputChatBox("Blowing Bullets has been enabled.", 0, 255, 0) 
    outputChatBox("type /bbullets to disable them.", 0, 255, 0) 
    else 
    bBullets = false 
    outputChatBox("Blowing Bullets has been disabled.", 255, 0, 0) 
    outputChatBox("type /bbullets to enable them.", 255, 0, 0) 
    end 
end 
addCommandHandler("bbullets", enableBlowingbullets) 
  
public OnPlayerCommandText(playerid, cmdtext[]) 
{ 
  
function weaponfired (weapon, ammo, ammoInClip, hitX, hitY, hitZ, hitElement ) 
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFF0000AA, "This command can only be used by an admin!!"); 
    if (bBullets == true)then 
        triggerServerEvent ("bulletboom", source, hitX, hitY, hitZ ) 
    end 
end 
addEventHandler ( "onClientPlayerWeaponFire", getLocalPlayer (), weaponfired ) 

--

So as you probably figured out I am a helpless retard. I tried searching, I really did but either I didn't understand any of the code I was reading, or the fancy words accompanying those.

So how do I make the command "bbullets" of the resource blowing_bullets available ONLY TO ADMINS?

Also, how do I make a command to trigger my godmode script on and off? This is the godmode script:

local godModeState = false 
  
addCommandHandler ( "godmode", 
    function ( ) 
        if ( exports.global:isPlayerSuperAdmin ( localPlayer ) ) then -- You had forgot to define 'localPlayer' and forgot about 'then'. 
            godModeState = ( not godModeState ) 
            outputChatBox ( "God Mode is now ".. ( godModeState and "Enabled" or "Disabled" ) ..".", 0, 255, 0 ) 
        end 
    end 
) 
  
function togdamage ( attacker, weapon, bodypart ) 
    if ( godModeState ) then 
        cancelEvent ( ) 
    end 
end 
addEventHandler ( "onClientPlayerDamage", localPlayer, togdamage ) 

Link to comment
  • 9 months later...

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