Jump to content

help with command to two teams


TroyBoy

Recommended Posts

look i wana do this command:

addCommandHandler( "go", gotoplayerposition ) 
function gotoplayerposition ( theplayer, command ) 
        local playerTeam = getPlayerTeam ( source ) 
    if ( playerTeam ) then 
                local name = getTeamName ( playerTeam ) 
                if name == "Owner" then 
                        local find = findPlayer( player ) 
                        if find == false then 
                                outputChatbox ( "No player with that name." ) 
                        else 
                                local px, py, pz = getElementPosition ( find ) 
                                setElementPosition (source, px, py, pz ) 
                        end 
                else 
                        outputChatbox ( "Not an admin!" ) 
                end 
        end 
end 

for the owner and the admin team but when i try to do this i have an error help please

Link to comment

Server

addCommandHandler( "go", 
    function ( player, _,name ) 
        local playerTeam = getPlayerTeam ( player ) 
        if playerTeam then 
            local name = getTeamName ( playerTeam ) 
            if name == "Owner" then 
                local find = findPlayer( name ) 
                if not find then 
                    outputChatBox ( "No player with that name." ) 
                else 
                    local px, py, pz = getElementPosition ( find ) 
                    setElementPosition ( player, px, py, pz ) 
                end 
            else 
                outputChatBox ( "Not an admin!" ) 
            end 
        end 
    end 
)    

Edited by Guest
Link to comment

WARNING: myserver\OwnerTeam.lua:59: Bad argument @ 'addCommandHandler' [Expected function at argument 2, got nil

this is this lines this is when i put only owner with the admin this is the error:

[2012-02-15 20:04:38] SCRIPT ERROR: myserver\OwnerTeam.lua:81: 'end' expected (to close 'function' at line 60) near ''

[2012-02-15 20:04:38] WARNING: Loading script failed: myserver\OwnerTeam.lua:81: 'end' expected (to close 'function' at line 60) near ''

Link to comment
addCommandHandler( "go", 
    function ( player, _,name ) 
        local playerTeam = getPlayerTeam ( player ) 
        if playerTeam then 
            local name = getTeamName ( playerTeam ) 
            if name == "Owner" or name == "Admin" then 
                local find = findPlayer( name ) 
                if not find then 
                    outputChatBox ( "No player with that name." ) 
                else 
                    local px, py, pz = getElementPosition ( find ) 
                    setElementPosition ( player, px, py, pz ) 
                end 
            else 
                outputChatBox ( "Not an admin or owner!" ) 
            end 
        end 
    end 
)    

Link to comment
addCommandHandler( "set_team", 
    function ( player, _,name ) 
        if getPlayerName( player ) == 'TroyBoy' then 
            local find = findPlayer( name ) 
            if not find then 
                outputChatBox ( "No player with that name." ) 
            else 
                setPlayerTeam( find,getTeamFromName( 'Owner' ) ) 
            end 
        else 
            outputChatBox ( "You can't use this command!" ) 
        end 
    end 
)    

/set_team [nickname]

Link to comment

and can you do this 2 commands only to admin and owner please:

addCommandHandler( 'givemoney', 
    function( source,_,player,amount ) 
        local find = findPlayer( player ) 
        if find then 
            if amount then 
                givePlayerMoney( find,tonumber( amount ) ) 
                outputChatBox( '[givemoney]:You transfer $'..amount..' to '..getPlayerName( find ),source,255,0,0 ) 
            else 
                outputChatBox( '[givemoney]:/givemoney [playername][amount]!',source,255,0,0 ) 
            end  
        else 
            outputChatBox( '[givemoney]:Player not found!',source,255,0,0 ) 
        end 
    end 
)    
function consoleGiveCash ( thePlayer, command, amount ) --when the givecash command is called 
    givePlayerMoney ( thePlayer, amount ) --give the player money according to the amount 
end 
addCommandHandler ( "givecash", consoleGiveCash  ) --add a handler function for the command "givecash" 
addCommandHandler( 'cv', 
    function( player,_,id_name ) 
        local x,y,z = getElementPosition( player ) 
        local model = getVehicleModelFromName( id_name ) 
        if not model then 
            model = tonumber( id_name ) 
        end 
        if  createVehicle( model,x+1,y,z ) then 
            outputChatBox( 'Success created: '..tostring( getVehicleNameFromModel( model ) ) ) 
        else 
            outputChatBox( 'Vehicle not created: '..tostring( getVehicleNameFromModel( model ) ) ) 
        end 
    end 
) 

Link to comment

Server

addCommandHandler( 'givemoney', 
    function( player,_,nick,amount ) 
        local playerTeam = getPlayerTeam ( player ) 
        if playerTeam then 
            local name = getTeamName ( playerTeam ) 
            if name == "Owner" or name == "Admin" then 
                local find = findPlayer( nick ) 
                if find then 
                    if amount then 
                        givePlayerMoney( find,tonumber( amount ) ) 
                        outputChatBox( '[givemoney]:You transfer $'..amount..' to '..getPlayerName( find ),player,255,0,0 ) 
                    else 
                        outputChatBox( '[givemoney]:/givemoney [playername][amount]!',player,255,0,0 ) 
                    end  
                else 
                    outputChatBox( '[givemoney]:Player not found!',player,255,0,0 ) 
                end 
            else 
                outputChatBox ( "Not an admin or owner!" )   
            end 
        end      
    end 
)    
  
function consoleGiveCash ( player, command, amount ) --when the givecash command is called 
    local playerTeam = getPlayerTeam ( player ) 
    if playerTeam then 
        local name = getTeamName ( playerTeam ) 
        if name == "Owner" or name == "Admin" then 
            givePlayerMoney ( player, tonumber( amount ) ) --give the player money according to the amount 
        else 
            outputChatBox ( "Not an admin or owner!" ) 
        end  
    end      
end 
addCommandHandler ( "givecash", consoleGiveCash  ) --add a handler function for the command "givecash" 
  
addCommandHandler( 'cv', 
    function( player,_,id_name ) 
        local playerTeam = getPlayerTeam ( player ) 
        if playerTeam then 
            local name = getTeamName ( playerTeam ) 
            if name == "Owner" or name == "Admin" then 
                local x,y,z = getElementPosition( player ) 
                local model = getVehicleModelFromName( id_name ) 
                if not model then 
                    model = tonumber( id_name ) 
                end 
                if  createVehicle( model,x+1,y,z ) then 
                    outputChatBox( 'Success created: '..tostring( getVehicleNameFromModel( model ) ) ) 
                else 
                    outputChatBox( 'Vehicle not created: '..tostring( getVehicleNameFromModel( model ) ) ) 
                end 
            else 
                outputChatBox ( "Not an admin or owner!" )   
            end 
        end          
    end 
) 

You should continue to do everything myself.

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