Jump to content

GUI - need little help


isa_Khamdan

Recommended Posts

  • Replies 50
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Well, you can use addCommandHandler or the event onConsole.

Hmm I think I go ahead and upgrade the script to next level and add the vehicles resources to it.

just one question I made the gui to spawn a car from the gridlist how can I add a limit one vehicle per person and if you already have one it will not spawn another one?

Else I want to make the created vehicle damageproof

function createMyVehicle(vehicleid,x,y,z) 
  
    -- check all the arguments exist 
  
    if vehicleid and x and y and z then 
  
        createVehicle(vehicleid,x,y,z) 
  
    end 
  
end 

Link to comment

Hmm I guess I will just keep this GUI simple as it my first can you just tell me how to use addcommandhandler or Onconsole to make my script work?

That's the code triggerd on the server side

addEvent("Spawn",true) 
addEventHandler("Spawn",root, 
  
  
  
    function() 
  
        local account = getPlayerAccount(source) -- get account element from player element 
  
        local accname = getAccountName(account) -- get account name from account element 
  
        if isObjectInACLGroup("user."..accname,aclGetGroup("PCS")) then 
  
        outputConsole(accname) 
  
        
  
    end 
  
end 
  
) 

I want the output to be a command

Link to comment

I made this but it didn't work

function input_Console ( accname ) --when a player types in the console 
    local account = getPlayerAccount(source) -- get account element from player element 
    local accname = getAccountName(account) -- get account name from account element 
    if ( getElementType ( source ) == "player" ) then 
        local command = accname  
  
  
         
    end 
end 
addEventHandler ( "onConsole", getRootElement(), input_Console ) 

Link to comment

client side part

addEventHandler("onClientGUIClick", root, function(Spawn) 
  if source == PCSbutton3 then 
   
            triggerServerEvent("Spawn",localPlayer) 
  
  
        end 
   end 
)    

server side part

  
  
 addEvent("Spawn",true) 
addEventHandler("Spawn",root, 
  
    function() 
  
        local account = getPlayerAccount(source) -- get account element from player element 
  
        local accname = getAccountName(account) -- get account name from account element 
  
        if isObjectInACLGroup("user."..accname,aclGetGroup("PCS")) then 
  
        outputConsole(accname) 
  
        
  
    end 
  
end 
  
) 
  
function input_Console ( accname ) --when a player types in the console 
    local account = getPlayerAccount(source) -- get account element from player element 
    local accname = getAccountName(account) -- get account name from account element 
    if ( getElementType ( source ) == "player" ) then 
        local command = accname  
  
  
         
    end 
end 
addEventHandler ( "onConsole", getRootElement(), input_Console ) 

Link to comment
You aren't reading what I say? that doesn't make any sense...

look , when you click the gui it will output the account name to the console as a message I want it to be a command not a message , The command is from another resource and it's being used to warp a vehicle to the player

function warpC(source) 
local x,y,z2 = getElementPosition(source) 
    if (getPlayerSerial(source)=="0396C6F543425FFE37A326883D73B4F4") then 
       setElementPosition ( C, x, y-3, z2+1 ) 
        else 
            r,b,g2 = math.random(0, 255), math.random(0, 255), math.random(0, 255) 
        outputChatBox( "* Not Nexus", source,r,b,g2, true ) 
    end 
end     
addCommandHandler ( "Nexus", warpC ) 

Link to comment
You're welcome.

Hmm I am getting one problem now this script works 100% now but only for me because it say my name as a command how can I make it get the player name and use it as a command

addEvent("Spawn",true) 
addEventHandler("Spawn",root, 
  
  
  
    function() 
  
        local account = getPlayerAccount(source) -- get account element from player element 
  
        local accname = getAccountName(account) -- get account name from account element 
  
        if isObjectInACLGroup("user."..accname,aclGetGroup("PCS")) then 
         
        executeCommandHandler( "Nexus", source ) 
  
        
  
    end 
  
end 
  
) 

in this line " executeCommandHandler( "Nexus", source ) "

I want to replace Nexus with player name so anyone click the gui button it will place his name as a command

Link to comment
  • Moderators
in this line " executeCommandHandler( "Nexus", source ) "

I want to replace Nexus with player name so anyone click the gui button it will place his name as a command

This function will call all the attached functions of an existing console command, for a specified player.

What do you mean by "use it as a command"?

Link to comment
in this line " executeCommandHandler( "Nexus", source ) "

I want to replace Nexus with player name so anyone click the gui button it will place his name as a command

This function will call all the attached functions of an existing console command, for a specified player.

What do you mean by "use it as a command"?

Nexus is my account name and I use it as a command to spawn my private car so I want the executecommand handler to always use player name as a command

executeCommandHandler( "Here is the player name", source )

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