Jump to content

group personal commands


Samking

Recommended Posts

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?

Link to comment
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


   
    

Link to comment

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

Link to comment
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
Link to comment
 
-- 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

 

Link to comment
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.....

 

Link to comment
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.

Link to comment

 

 

 

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