Jump to content

GUI Help


Recommended Posts

Posted

Well I have created a Ped and here is my ped code

ped1 = createPed (280, 1546, -1680.55, 13.56) --Police NPC 
setPedRotation ( ped1, 90 ) 
setElementFrozen ( ped1, true ) 

now, i have a GUI, how can I make it show up when i click on that NPC with the cursor??

Posted
addEventHandler ( "onElementClicked", ped1, 
    function ( ) 
        outputChatBox ( "Clicked ped1!" ) 
    end 
) 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted (edited)

Alright! thanks for helping ;D

Edit: got this error,

ERROR: wip\script.lua:9: attempt to call global 'guiCreateWindow' (a nil value)

Edited by Guest
Posted

You're welcome.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

I'm sure that your script is set as server side, GUI is client side only.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

yea, i forgot about it lolz, but still it's not working lol, when i click on the ped nothing shows up and no errors are on there

EDIT: Code

ped1 = createPed (280, 1546, -1680.55, 13.56) --Police NPC 
setElementData(ped1,"message","Police, click on NPC to get job") 
setPedRotation ( ped1, 90 ) 
setElementFrozen ( ped1, true ) 
  
addEventHandler ( "onElementClicked", ped1, 
 function ( ) 
jobPanel = guiCreateWindow(259,170,515,408,"Police",false) 
acceptButton = guiCreateButton(93,360,119,39,"Accept",false,jobPanel) 
declineButton = guiCreateButton(258,360,123,39,"Decline",false,jobPanel) 
descLabel = guiCreateLabel(21,44,90,16,"Job Description",false,jobPanel) 
descMemo = guiCreateMemo(25,78,478,273,"",false,jobPanel) 
guiMemoSetReadOnly(descMemo,true) 
    end 
) 
  

Posted

Post your entire script.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Server:

ped1 = createPed (280, 1546, -1680.55, 13.56) --Police NPC 
setElementData(ped1,"message","Police, click on NPC to get job") 
setPedRotation ( ped1, 90 ) 
setElementFrozen ( ped1, true ) 
exports [ "extra_health" ]:setElementExtraHealth(ped1, 50000000) 
  
addEventHandler ( "onElementClicked", ped1, 
 function ( ) 
     end 
) 
  

Client

function changeVisibility ( ) 
        guiSetVisible (policeWindow,true) 
end 
policeWindow = guiCreateWindow(259,170,515,408,"Police",true) 
acceptButton = guiCreateButton(93,360,119,39,"Accept",false,policeWindow) 
declineButton = guiCreateButton(258,360,123,39,"Decline",false,policeWindow) 
descLabel = guiCreateLabel(21,44,90,16,"Job Description",false,policeWindow) 
descMemo = guiCreateMemo(25,78,478,273,"",false,policeWindow) 
guiMemoSetReadOnly(descMemo,true) 
  

Posted

When are you executing: "changeVisibility" function?

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Try this:

Server:

ped1 = createPed (280, 1546, -1680.55, 13.56) --Police NPC 
setElementData(ped1,"message","Police, click on NPC to get job") 
setPedRotation ( ped1, 90 ) 
setElementFrozen ( ped1, true ) 
exports [ "extra_health" ]:setElementExtraHealth(ped1, 50000000) 
  
addEventHandler ( "onElementClicked", ped1, 
 function ( ) 
triggerClientEvent ( source, "changeVisibility",  source ) 
     end 
) 
  

Client

policeWindow = guiCreateWindow(259,170,515,408,"Police",true) 
guiSetVisible ( policeWindow, false ) 
acceptButton = guiCreateButton(93,360,119,39,"Accept",false,policeWindow) 
declineButton = guiCreateButton(258,360,123,39,"Decline",false,policeWindow) 
descLabel = guiCreateLabel(21,44,90,16,"Job Description",false,policeWindow) 
descMemo = guiCreateMemo(25,78,478,273,"",false,policeWindow) 
guiMemoSetReadOnly(descMemo,true) 
  
function changeVisibility ( ) 
        guiSetVisible (policeWindow,true) 
        showCursor ( true ) 
end 
addEvent ( "changeVisibility", true ) 
addEventHandler ( "changeVisibility", root, changeVisibility ) 
  

Need paid scripter just pm me i will accept every job!

Posted

You're welcome.

@TheIceman: 'source' of onElementClicked is the element clicked, not who clicked it.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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