Jump to content

group personal commands


Samking

Recommended Posts

Posted
9 hours ago, MIKI785 said:

You could use ACL, see ACL functions on the wiki.. or if you mean teams then check for the team using getPayerTeam.

Can you make one for me, please?

I make but...

I fail :(

 

Posted (edited)
7 minutes ago, Samking said:

Can you make one for me, please?

I make but...

I fail :(

Try to put some code together, when you do that, post it here, and we'll help. You'll need:

isObjectInACLGroup

 

Edited by Saml1er
Posted

 

2 minutes ago, Saml1er said:

Try to put some code together, when you do that, post it here, and we'll help. You'll need:


isObjectInACLGroup

 

Thanks :D

 

I will try now 

Posted
2 hours ago, Saml1er said:

Try to put some code together, when you do that, post it here, and we'll help. You'll need:


isObjectInACLGroup

 

I am shy to show ma script because a lot of mistakes I have done in it.

Can you make one for me, please?

Posted
2 hours ago, Saml1er said:

Try to put some code together, when you do that, post it here, and we'll help. You'll need:


isObjectInACLGroup

 

     local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) 
     if isObjectInACLGroup ("user."..accName, aclGetGroup ( "VIP" ) ) then 
           giveCash ( thePlayer )  
           end
end
)
     
function giveCash (player)
    givePlayerMoney(player,1000000)
                outputChatBox ("$-----------------------------------------------------------------------------------------------$",source,0, 255, 0,true)
                outputChatBox ("The player'"..getPlayerName(player).."' is rich now because he ",source,250, 255, 0,true)
                outputChatBox ("Has received 10m$ ",source,0, 255, 221,true)
                outputChatBox ("$-----------------------------------------------------------------------------------------------$",source,0, 255, 0,true)
    end
addCommandHandler("givemecash",giveCash) 


function giveCash (player)
    givePlayerMoney(player,99999999)
                outputChatBox ("$---------------------------------------------------------------------------------------------$",source,0, 255, 0,true)
                outputChatBox ("The player'"..getPlayerName(player).."' is extremely rich now because he ",source,250, 255, 0,true)
                outputChatBox ("  Has received 99m$ ",source,0, 255, 221,true)
                outputChatBox ("$---------------------------------------------------------------------------------------------$",source,0, 255, 0,true)
    end


   
    

Posted

@Samking

-- if you remove this line with "local" keyword, these
-- functions will be visible to other files in the resource.
-- Currently, you can only use them within this file only.
local isPlayerInGroup, giveCash
     
local function giveCashCommand (player)
    if isPlayerInGroup (player, "VIP") then
        giveCash (player)
    else
        outputChatBox ("You are not in the VIP group", player)
    end 
end
addCommandHandler("givemecash", giveCashCommand) 


function giveCash (player)
    givePlayerMoney(player,99999999)
    outputChatBox ("$---------------------------------------------------------------------------------------------$",root,0, 255, 0,true)
    outputChatBox ("The player'"..getPlayerName(player).."' is extremely rich now because he ",root,250, 255, 0,true)
    outputChatBox ("  Has received 99m$ ", root,0, 255, 221,true)
    outputChatBox ("$---------------------------------------------------------------------------------------------$",root,0, 255, 0,true)
end

function isPlayerInGroup (player, group)
    local playerAccount = getPlayerAccount ( thePlayer )
    if playerAccount then
        local accName = getAccountName ( playerAccount ) 
        if isObjectInACLGroup ("user."..accName, aclGetGroup ( group ) ) then 
            -- the player is in the group, return true 
            return true
        end
    end
    -- the player is not in the group, return false
    return false
end

I haven't tested the code, but I quickly came up with this.

Posted

thanks, I will try

 

if the player in VIP group type  /givemecash   command this will visible to those who are in VIP group?

or all?

 

Posted (edited)
23 hours ago, Saml1er said:

@Samking


-- if you remove this line with "local" keyword, these
-- functions will be visible to other files in the resource.
-- Currently, you can only use them within this file only.
local isPlayerInGroup, giveCash
     
local function giveCashCommand (player)
    if isPlayerInGroup (player, "VIP") then
        giveCash (player)
    else
        outputChatBox ("You are not in the VIP group", player)
    end 
end
addCommandHandler("givemecash", giveCashCommand) 


function giveCash (player)
    givePlayerMoney(player,99999999)
    outputChatBox ("$---------------------------------------------------------------------------------------------$",root,0, 255, 0,true)
    outputChatBox ("The player'"..getPlayerName(player).."' is extremely rich now because he ",root,250, 255, 0,true)
    outputChatBox ("  Has received 99m$ ", root,0, 255, 221,true)
    outputChatBox ("$---------------------------------------------------------------------------------------------$",root,0, 255, 0,true)
end

function isPlayerInGroup (player, group)
    local playerAccount = getPlayerAccount ( thePlayer )
    if playerAccount then
        local accName = getAccountName ( playerAccount ) 
        if isObjectInACLGroup ("user."..accName, aclGetGroup ( group ) ) then 
            -- the player is in the group, return true 
            return true
        end
    end
    -- the player is not in the group, return false
    return false
end

I haven't tested the code, but I quickly came up with this.

I 've got an error  

this gives Only  Output that "You are not in the VIP group"

I set my self in VIP group but still give output "You are not in the VIP group"/>

And in console 

Warning: givecash/script.lua:22: Bad argument @ getPlayerAccount [Expected element at argument 1 got nil]

 

Edited by Samking
Mistake
Posted
 
-- if you remove this line with "local" keyword, these
-- functions will be visible to other files in the resource.
-- Currently, you can only use them within this file only.
local isPlayerInGroup, giveCash
     
local function giveCashCommand (player)
    if isPlayerInGroup (player, "VIP") then
        giveCash (player)
    else
        outputChatBox ("You are not in the VIP group", player)
    end 
end
addCommandHandler("givemecash", giveCashCommand) 


function giveCash (player)
    givePlayerMoney(player,99999999)
    outputChatBox ("$---------------------------------------------------------------------------------------------$",root,0, 255, 0,true)
    outputChatBox ("The player'"..getPlayerName(player).."' is extremely rich now because he ",root,250, 255, 0,true)
    outputChatBox ("  Has received 99m$ ", root,0, 255, 221,true)
    outputChatBox ("$---------------------------------------------------------------------------------------------$",root,0, 255, 0,true)
end

function isPlayerInGroup (thePlayer, group)
    local playerAccount = getPlayerAccount ( thePlayer )
    if playerAccount then
        local accName = getAccountName ( playerAccount ) 
        if isObjectInACLGroup ("user."..accName, aclGetGroup ( group ) ) then 
            -- the player is in the group, return true 
            return true
        end
    end
    -- the player is not in the group, return false
    return false
end

 

Posted
20 minutes ago, Dimos7 said:

 
-- if you remove this line with "local" keyword, these
-- functions will be visible to other files in the resource.
-- Currently, you can only use them within this file only.
local isPlayerInGroup, giveCash
     
local function giveCashCommand (player)
    if isPlayerInGroup (player, "VIP") then
        giveCash (player)
    else
        outputChatBox ("You are not in the VIP group", player)
    end 
end
addCommandHandler("givemecash", giveCashCommand) 


function giveCash (player)
    givePlayerMoney(player,99999999)
    outputChatBox ("$---------------------------------------------------------------------------------------------$",root,0, 255, 0,true)
    outputChatBox ("The player'"..getPlayerName(player).."' is extremely rich now because he ",root,250, 255, 0,true)
    outputChatBox ("  Has received 99m$ ", root,0, 255, 221,true)
    outputChatBox ("$---------------------------------------------------------------------------------------------$",root,0, 255, 0,true)
end

function isPlayerInGroup (thePlayer, group)
    local playerAccount = getPlayerAccount ( thePlayer )
    if playerAccount then
        local accName = getAccountName ( playerAccount ) 
        if isObjectInACLGroup ("user."..accName, aclGetGroup ( group ) ) then 
            -- the player is in the group, return true 
            return true
        end
    end
    -- the player is not in the group, return false
    return false
end

 

is this code is correct?

 

30 minutes ago, Saml1er said:

I made a mistake:


function isPlayerInGroup (player, group)
    local playerAccount = getPlayerAccount ( thePlayer )

TO


function isPlayerInGroup (player, group)
    local playerAccount = getPlayerAccount ( player )

 

still the same.....

 

Posted
1 hour ago, Samking said:

still the same.....

Did you restart the resource after fixing the problem? Check VIP group within acl in admin panel, see if your account name is there. If it still doesn't work, then copy-paste your acl.xml here.

Posted (edited)

 

 

 

11 minutes ago, Saml1er said:

Did you restart the resource after fixing the problem? Check VIP group within acl in admin panel, see if your account name is there. If it still doesn't work, then copy-paste your acl.xml here.

Thanks for helping me

 

Edited by Samking

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