blackpenguin98 Posted May 4, 2013 Share Posted May 4, 2013 I want to make that when someone enter a colshape a gui opens. Meta: Client: addEventHandler ( "onResourceStart", getRootElement(), CreateGui ) function CreateGui ( theElement, matchingDimension ) local x = 0.375 local y = 0.375 local width = 0.25 local height = 0.25 local twindow = guiCreateWindow ( x, y, width, height, "Trucker Job", true ) x = 0.400 y = 0.400 width = 0.05 height = 0.05 guiCreateLabel ( x, y, width, height, "In trucker job you need to deliver some stuff to the gas stations.", true, twindow ) x = 0.100 y = 0.150 width = 0.02 height = 0.02 local conb = guiCreateButton ( x, y, width, height, "Confirm", true, twindow ) x = 0.400 local canb = guiCreateButton ( x, y, width, height, "Cancel", true, twindow ) guiSetVisible( twindow, false ) end addEventHandler ( "onClientClick", conb, Confirm ) addEventHandler ( "onClientClick", canb, Cancel ) function Cancel ( button, state, absoluteX, absoluteY, worldX, worldY, worldZ, clickedElement ) guiSetVisible( twindow, false ) showCursor ( false ) end addEventHandler( "onClientColShapeHit", tc, check ) function check () guiSetVisible( twindow, true ) showCursor ( true ) end Server: function tped () local ped = createPed ( 133, 165.5587, -27.8196, 1.5781 ) local attached = createBlipAttachedTo ( ped, 60 ) local tc = createColTube ( 165.5587, -27.8196, 1.5781, 10, 5) setElementFrozen ( ped, true ) setBlipVisibleDistance ( attached, 800 ) end addEventHandler ( "onResourceStart", getRootElement(), tped ) function Confirm ( button, state, absoluteX, absoluteY, worldX, worldY, worldZ, clickedElement ) local tt = createTeam ( "Trucker", 255, 255, 0 ) setElementModel ( thePlayer, 133 ) setPlayerTeam ( thePlayer, "Trucker" ) end Link to comment
WASSIm. Posted May 4, 2013 Share Posted May 4, 2013 try this Client: addEventHandler ( "onResourceStart", getRootElement(), CreateGui ) function CreateGui ( theElement, matchingDimension ) local x = 0.375 local y = 0.375 local width = 0.25 local height = 0.25 local twindow = guiCreateWindow ( x, y, width, height, "Trucker Job", true ) x = 0.400 y = 0.400 width = 0.05 height = 0.05 guiCreateLabel ( x, y, width, height, "In trucker job you need to deliver some stuff to the gas stations.", true, twindow ) x = 0.100 y = 0.150 width = 0.02 height = 0.02 local conb = guiCreateButton ( x, y, width, height, "Confirm", true, twindow ) x = 0.400 local canb = guiCreateButton ( x, y, width, height, "Cancel", true, twindow ) guiSetVisible( twindow, false ) end addEventHandler ( "onClientClick", conb, Confirm ) addEventHandler ( "onClientClick", canb, Cancel ) function Cancel ( button, state, absoluteX, absoluteY, worldX, worldY, worldZ, clickedElement ) guiSetVisible( twindow, false ) showCursor ( false ) end addEventHandler( "onClientColShapeHit", tc, check ) function check (hitElement) if getElementType(hitElement) == "player" and (hitElement == localPlayer) then if not guiGetVisible(twindow) then guiSetVisible( twindow, true ) showCursor ( true ) end end end Link to comment
blackpenguin98 Posted May 4, 2013 Author Share Posted May 4, 2013 When I go to the location where I create the colshape anything happen, i think that the problem is that the colshape isnt created correctly. Please help Link to comment
Castillo Posted May 4, 2013 Share Posted May 4, 2013 That script will never work, reasons: 1: You are using the event: "onResourceStart" on a client side script, should be: "onClientResourceStart". 2: You are adding the event handlers BEFORE you create the functions. Link to comment
blackpenguin98 Posted May 5, 2013 Author Share Posted May 5, 2013 thanks i will fix it Link to comment
blackpenguin98 Posted May 5, 2013 Author Share Posted May 5, 2013 It doesnt work .-. I am a new scripter and I want to learn please Help me this is the code: Server: function tped () local ped = createPed ( 133, 165.5587, -27.8196, 1.5781 ) local attached = createBlipAttachedTo ( ped, 60 ) setElementFrozen ( ped, true ) setBlipVisibleDistance ( attached, 800 ) end addEventHandler ("onResourceStart", getResourceRootElement ( getThisResource () ), tped) function Confirm ( button, state, absoluteX, absoluteY, worldX, worldY, worldZ, clickedElement ) local tt = createTeam ( "Trucker", 255, 255, 0 ) setElementModel ( thePlayer, 133 ) setPlayerTeam ( thePlayer, "Trucker" ) end Client: function CreateGui ( theElement, matchingDimension ) local x = 0.375 local y = 0.375 local width = 0.25 local height = 0.25 local twindow = guiCreateWindow ( x, y, width, height, "Trucker Job", true ) x = 0.400 y = 0.400 width = 0.05 height = 0.05 guiCreateLabel ( x, y, width, height, "In trucker job you need to deliver some stuff to the gas stations.", true, twindow ) x = 0.100 y = 0.150 width = 0.02 height = 0.02 local conb = guiCreateButton ( x, y, width, height, "Confirm", true, twindow ) x = 0.400 local canb = guiCreateButton ( x, y, width, height, "Cancel", true, twindow ) guiSetVisible( twindow, false ) end addEventHandler ("onClientResourceStart", getResourceRootElement ( getThisResource () ), CreateGui) addEventHandler ( "onClientClick", conb, Confirm ) addEventHandler ( "onClientClick", canb, Cancel ) function Cancel ( button, state, absoluteX, absoluteY, worldX, worldY, worldZ, clickedElement ) guiSetVisible( twindow, false ) showCursor ( false ) end function nigga () local tc = createColTube ( 165.5587, -27.8196, 1.5781, 10, 5) end addEventHandler ("onClientResourceStart", getResourceRootElement ( getThisResource () ), nigga) function check (hitElement) if getElementType(hitElement) == "player" and (hitElement == localPlayer) then if not guiGetVisible(twindow) then guiSetVisible( twindow, true ) showCursor ( true ) end end end addEventHandler( "onClientColShapeHit", tc, check ) Link to comment
xXMADEXx Posted May 5, 2013 Share Posted May 5, 2013 use: /debugscript 3 to find what is wrong with it... Link to comment
Mega9 Posted May 5, 2013 Share Posted May 5, 2013 You still haven't done what Castillo pointed out for you. Your code has many errors and functions which don't make sense at all. For example: You're using onResourceStart (which is server-side) in client-side script, using onClientClick instead of onClientGUIClick etc. Show us that you actually made all of this by fixing some of said things so we could help you. Link to comment
blackpenguin98 Posted May 5, 2013 Author Share Posted May 5, 2013 But what other error i have? how I know what errors are? Im new in scripting, this is my first script and I want to make that a ped whit a colshape so that when you enter the col a gui is created so you can accept the job or not. (sorry for bad english) Link to comment
PaiN^ Posted May 5, 2013 Share Posted May 5, 2013 You can see your error using the debug ( wright 'debugscript 3' in the console ) . + They have allready told you your mistakes ! Link to comment
blackpenguin98 Posted May 5, 2013 Author Share Posted May 5, 2013 When i write "debugscript 3" in console it says me "incorrect client type for this commands" Link to comment
Mega9 Posted May 5, 2013 Share Posted May 5, 2013 Exactly, because you're using SERVER side functions/events in CLIENT side. Re-read the wiki to find a difference between those two. Link to comment
blackpenguin98 Posted May 6, 2013 Author Share Posted May 6, 2013 thanks for your help Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now