damien111 Posted November 12, 2012 Posted November 12, 2012 hey, im working on the beta ver. of my disk system, the very basics, but, i havent scripted in a while. I cant seem to find out whats wrong with this. I cant get it to disappear on start, then when you go into the marker, show up. Please help, Thanks! server disk = createPickup ( 1685.6552734375, 993.8076171875, 10.8203125, 3, 1277 ) function killPlayer() killPlayer(source) end addEvent("killPlayer", true) addEventHandler("killPlayer", root, joinSAPD) function showgui() triggerClientEvent(source,"createGUI",source) end addEventHandler("onPickupHit",disk,showgui) client GUIEditor = { gridlist = {}, button = {}, window = {}, } GUIEditor.window[1] = guiCreateWindow(56, 55, 680, 284, "", false) guiWindowSetSizable(GUIEditor.window[1], false) GUIEditor.button[1] = guiCreateButton(381, 46, 271, 58, "Kill Yourself!", false, GUIEditor.window[1]) GUIEditor.button[2] = guiCreateButton(381, 115, 271, 58, "Repair Car", false, GUIEditor.window[1]) GUIEditor.button[3] = guiCreateButton(381, 183, 271, 58, "Spawn Car", false, GUIEditor.window[1]) GUIEditor.gridlist[1] = guiCreateGridList(37, 50, 316, 182, false, GUIEditor.window[1]) guiGridListAddColumn(GUIEditor.gridlist[1], "Car NAme", 0.3) guiGridListAddColumn(GUIEditor.gridlist[1], "Damage", 0.3) guiGridListAddColumn(GUIEditor.gridlist[1], "Price To Repair", 0.3) function hideGUI ( ) guiSetVisible( GUIEditor.window[1] , false) end addEventHandler ( "onResourceStart", getRootElement(), hideGUI ) local diskmarker = createMarker( 1685.6552734375, 993.8076171875, 10.8203125, "Cylinder", 1.5, 0, 0, 255, 255) addEvent("createGUI",true) addEventHandler("createGUI",getRootElement(), function() guiSetVisible( GUIEditor.window[1] , true) showCursor(true) end ) function KillHim() triggerServerEvent("killPlayer",localPlayer) guiSetVisible( GUIEditor.window[1] , false) showCursor(false) end addEventHandler("onClientGUIClick", GUIEditor.button[1], KillHim, false)
Castillo Posted November 12, 2012 Posted November 12, 2012 Well, that's because you used: "onResourceStart", that's a server side event. You must add: guiSetVisible after: GUIEditor.window[1] = guiCreateWindow(56, 55, 680, 284, "", false) Like this: GUIEditor.window[1] = guiCreateWindow(56, 55, 680, 284, "", false) guiSetVisible ( GUIEditor.window[1], false ) And btw, this: function killPlayer() killPlayer(source) end addEvent("killPlayer", true) addEventHandler("killPlayer", root, joinSAPD) Never call a function like a native one, unless you are going to replace it. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
damien111 Posted November 12, 2012 Author Posted November 12, 2012 Hmm.. Alrighty. That Fixed A Problem, But It Wont Load The Menu When I Pickup The Disk Pickup.
damien111 Posted November 12, 2012 Author Posted November 12, 2012 also edited addEventHandler("killPlayer", root, joinSAPD) to addEventHandler("killem", root, killPlayer)
myonlake Posted November 12, 2012 Posted November 12, 2012 Using onPickupHit server-side may do some synchronization errors, experience tells, and it's a lot easier anyways. Server-side addEvent("killPlayer", true) addEventHandler("killPlayer", root, function() killPlayer(source) end ) Client-side local disk = createPickup(1685.6552734375, 993.8076171875, 10.8203125, 3, 1277) addEventHandler("onClientPickupHit", disk, function(hitElement, matchingDimension) if getElementType(hitElement) == "player" and matchingDimension then if not isElement(GUIEditor.window[1]) then GUIEditor = { gridlist = {}, button = {}, window = {}, } GUIEditor.window[1] = guiCreateWindow(56, 55, 680, 284, "", false) guiWindowSetSizable(GUIEditor.window[1], false) GUIEditor.button[1] = guiCreateButton(381, 46, 271, 58, "Kill Yourself!", false, GUIEditor.window[1]) GUIEditor.button[2] = guiCreateButton(381, 115, 271, 58, "Repair Car", false, GUIEditor.window[1]) GUIEditor.button[3] = guiCreateButton(381, 183, 271, 58, "Spawn Car", false, GUIEditor.window[1]) GUIEditor.gridlist[1] = guiCreateGridList(37, 50, 316, 182, false, GUIEditor.window[1]) guiGridListAddColumn(GUIEditor.gridlist[1], "Car NAme", 0.3) guiGridListAddColumn(GUIEditor.gridlist[1], "Damage", 0.3) guiGridListAddColumn(GUIEditor.gridlist[1], "Price To Repair", 0.3) addEventHandler("onClientGUIClick", GUIEditor.button[1], function() triggerServerEvent("killPlayer", localPlayer) destroyElement(GUIEditor.window[1]) showCursor(false) end ) showCursor(true) else guiBringToFront(GUIEditor.window[1]) end end end ) If I helped you, please click the like button on the right Thanks!
damien111 Posted November 12, 2012 Author Posted November 12, 2012 That helped alot! Thanks! But, i have another problem, it didnt rechonize the GUIEditor.window[1] as anything,so i changd the names of everything, but now it isnt childern to the window. D:
myonlake Posted November 12, 2012 Posted November 12, 2012 Have to make sure you have also changed the last argument of the GUI functions. If I helped you, please click the like button on the right Thanks!
damien111 Posted November 12, 2012 Author Posted November 12, 2012 Thanks! Now, i have a problem, how can i fix it so it only pops up for the 1 player? instead of everybody
myonlake Posted November 12, 2012 Posted November 12, 2012 It should open for one player only. It's client-side, you can't open it to all players however you wanted to. If you mean you want it to only show to an exact player name or team, then do.. getPlayerName getPlayerTeam getTeamName And such. If I helped you, please click the like button on the right Thanks!
damien111 Posted November 13, 2012 Author Posted November 13, 2012 Ok, it is opening for everyone but its client side. WHAT THE HELL GOING ON D: heres my script dl. , its to much code to post. http://up.ht/TWNhM8
Castillo Posted November 13, 2012 Posted November 13, 2012 You have to check if 'hitElement' is the localPlayer. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
damien111 Posted November 13, 2012 Author Posted November 13, 2012 How do i do that? I looking through the code and dont see where i would put that?
damien111 Posted November 13, 2012 Author Posted November 13, 2012 How do i do that? I looking through the code and dont see where i would put that?
Castillo Posted November 13, 2012 Posted November 13, 2012 addEventHandler("onClientPickupHit", disk, function(hitElement, matchingDimension) if ( getElementType(hitElement) == "player" and matchingDimension and hitElement == localPlayer ) then San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
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