Bilal135 Posted May 24, 2015 Share Posted May 24, 2015 function onGuiClick() if (source == GUIEditor.button[1]) then local rowa = guiGridListGetSelectedItem( GUIEditor.gridlist[1] ) local namea = guiGridListGetItemText( GUIEditor.gridlist[1], rowa, columna) local rowb = guiGridListGetSelectedItem( GUIEditor.gridlist[2] ) local nameb = guiGridListGetItemText( GUIEditor.gridlist[2], rowb, columnb) if namea == "Pershing Square" then triggerServerEvent("pershingsquarespawn", localPlayer) guiSetVisible(GUIEditor.window[1], false) showCursor(false) end if namea == "Idlewood Gas Station (IGS)" then triggerServerEvent("IGS", localPlayer) guiSetVisible(GUIEditor.window[1], false) showCursor(false) end if nameb == "Army (287)" then setElementModel(localPlayer, 287) end end end addEventHandler("onClientGUIClick", root, onGuiClick) It spawns me on the right place but it doesn't set my skin to 287......Any help? Link to comment
xeon17 Posted May 24, 2015 Share Posted May 24, 2015 What do you mean 'it spawns me on the right place' i don't see any spawn function in your code However, try this: function onGuiClick() if (source == GUIEditor.button[1]) then local rowa = guiGridListGetSelectedItem( GUIEditor.gridlist[1] ) local namea = guiGridListGetItemText( GUIEditor.gridlist[1], rowa, columna) local rowb = guiGridListGetSelectedItem( GUIEditor.gridlist[2] ) local nameb = guiGridListGetItemText( GUIEditor.gridlist[2], rowb, columnb) if namea == "Pershing Square" then triggerServerEvent("pershingsquarespawn", localPlayer) guiSetVisible(GUIEditor.window[1], false) showCursor(false) elseif namea == 'Idlewood Gas Station (IGS)' triggerServerEvent("IGS", localPlayer) guiSetVisible(GUIEditor.window[1], false) showCursor(false) elseif nameb == "Army (287)" then setElementModel(287) end end end addEventHandler("onClientGUIClick", root, onGuiClick) Link to comment
WhoAmI Posted May 24, 2015 Share Posted May 24, 2015 triggerServerEvent("pershingsquarespawn", localPlayer) Show your "pershingsquarespawn" event. You have to insert there setting skin's model. Not in client-side. Link to comment
Bilal135 Posted May 24, 2015 Author Share Posted May 24, 2015 What do you mean 'it spawns me on the right place' i don't see any spawn function in your codeHowever, try this: function onGuiClick() if (source == GUIEditor.button[1]) then local rowa = guiGridListGetSelectedItem( GUIEditor.gridlist[1] ) local namea = guiGridListGetItemText( GUIEditor.gridlist[1], rowa, columna) local rowb = guiGridListGetSelectedItem( GUIEditor.gridlist[2] ) local nameb = guiGridListGetItemText( GUIEditor.gridlist[2], rowb, columnb) if namea == "Pershing Square" then triggerServerEvent("pershingsquarespawn", localPlayer) guiSetVisible(GUIEditor.window[1], false) showCursor(false) elseif namea == 'Idlewood Gas Station (IGS)' triggerServerEvent("IGS", localPlayer) guiSetVisible(GUIEditor.window[1], false) showCursor(false) elseif nameb == "Army (287)" then setElementModel(287) end end end addEventHandler("onClientGUIClick", root, onGuiClick) I triggered those two events server side to spawn the player. +You missed an 'end' on line 46. Still doesn't work. EDIT: Looks like WhoAmI posted, let me try what you have said as well. Link to comment
Bilal135 Posted May 24, 2015 Author Share Posted May 24, 2015 @WhoAmI, here's my server side: --Place Events addEvent("pershingsquarespawn", true) addEvent("IGS", true) function onLogin() player = source triggerClientEvent(player, "onClientPlayerLogin", player) end addEventHandler("onPlayerLogin", root, onLogin) addEventHandler("pershingsquarespawn", root, function() spawnPlayer(source, 1473.6114501953, -1714.1791992188, 14.046875) fadeCamera(source, true) setCameraTarget(source, source) end ) addEventHandler("IGS", root, function() spawnPlayer(source, 1927.0316162109, -1764.384765625, 13.539072036743) fadeCamera(source, true) setCameraTarget(source, source) end ) Link to comment
Walid Posted May 24, 2015 Share Posted May 24, 2015 @Xeon that's wrong you need to add the element here anyways function onGuiClick() if (source == GUIEditor.button[1]) then local rowa = guiGridListGetSelectedItem( GUIEditor.gridlist[1] ) local namea = guiGridListGetItemText( GUIEditor.gridlist[1], rowa, columna) local rowb = guiGridListGetSelectedItem( GUIEditor.gridlist[2] ) local nameb = guiGridListGetItemText( GUIEditor.gridlist[2], rowb, columnb) if (rowa and rowa ~= -1) then if namea == "Pershing Square" then triggerServerEvent("pershingsquarespawn", localPlayer) elseif namea == 'Idlewood Gas Station (IGS)' triggerServerEvent("IGS", localPlayer) end elseif (rowb and rowb ~= -1) then if nameb == "Army (287)" then setElementModel(localPlayer,287) end end guiSetVisible(GUIEditor.window[1], false) showCursor(false) end end addEventHandler("onClientGUIClick", root, onGuiClick) Link to comment
Bilal135 Posted May 24, 2015 Author Share Posted May 24, 2015 It still doesn't set the skin, no errors in debug. Link to comment
Mr_Moose Posted May 24, 2015 Share Posted May 24, 2015 Your client side code will finish execute before the server code start's to execute, as you have a ping around 50 this means a ~50 ms delay which in reality means that you set the skin ID to 287 (only you will be able to se that as it's client side). Then, 50ms later the spawn function on the server is triggered: bool spawnPlayer ( player thePlayer, float x, float y, float z, [ int rotation = 0, int skinID = 0, int interior = 0, int dimension = 0, team theTeam = nil ] ) As you can see here, skinID is an optional argument in the spawn function which you haven't provided, that means it will set your skin to 0 (also known as CJ). So basically your code works, it does change your skin, but it also turns it back to CJ a few milliseconds later. I recommend you to set the skin either after calling the spawnPlayer, or supply that as an argument. Link to comment
Bilal135 Posted May 24, 2015 Author Share Posted May 24, 2015 Your client side code will finish execute before the server code start's to execute, as you have a ping around 50 this means a ~50 ms delay which in reality means that you set the skin ID to 287 (only you will be able to se that as it's client side). Then, 50ms later the spawn function on the server is triggered: bool spawnPlayer ( player thePlayer, float x, float y, float z, [ int rotation = 0, int skinID = 0, int interior = 0, int dimension = 0, team theTeam = nil ] ) As you can see here, skinID is an optional argument in the spawn function which you haven't provided, that means it will set your skin to 0 (also known as CJ). So basically your code works, it does change your skin, but it also turns it back to CJ a few milliseconds later. I recommend you to set the skin either after calling the spawnPlayer, or supply that as an argument. Thanks! 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