Jump to content

Permission To Do Command


Al3grab

Recommended Posts

Hi ,

i made an script that send money to all players in server by one command , and the code is client-side .. now i want to put permissions so just admin can use commad .. i knew it by the function :

hasObjectPermissionTo 

But its only server-side function !

-- the code

  
  
function moneyAll(commandName,Al3grab) 
    plrz = getElementsByType("player") 
    if (tonumber(Al3grab)) then 
    givePlayerMoney(Al3grab) 
    outputChatBox("#FF0000 *** ADMIN HAS GIVEN MONEY: #00FF00" .. amount .. "$ #FF0000 TO ALL PLAYERS *** ",255,0,0,true) 
    end 
end 
addCommandHandler( "sendall", moneyAll ) 
  
-- Al3grab = amount 
  

Any Help ? :D

Link to comment

This won't work, won't give all the players.

Make it server side.

addCommandHandler ( "sendall", 
function ( player, cmd, amount ) 
if hasObjectPermissionTo ( player, "function.banPlayer" ) then 
if tonumber ( amount ) ~= nil then 
for id, player in ipairs ( getElementsByType ( "player" ) ) do 
givePlayerMoney ( player, tonumber ( amount ) ) 
outputChatBox("#FF0000 *** ADMIN HAS GIVEN MONEY: #00FF00" .. amount .. "$ #FF0000 TO ALL PLAYERS *** ", root, 255,0,0,true) 
end) 

Link to comment
This won't work, won't give all the players.

Make it server side.

addCommandHandler ( "sendall", 
function ( player, cmd, amount ) 
if hasObjectPermissionTo ( player, "function.banPlayer" ) then 
if tonumber ( amount ) ~= nil then 
for id, player in ipairs ( getElementsByType ( "player" ) ) do 
givePlayerMoney ( player, tonumber ( amount ) ) 
outputChatBox("#FF0000 *** ADMIN HAS GIVEN MONEY: #00FF00" .. amount .. "$ #FF0000 TO ALL PLAYERS *** ", root, 255,0,0,true) 
end) 

Hello ,

thaks very much .. it worked after some edites :D

thank you

Link to comment

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