Bilal135 Posted May 24, 2015 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? "Get busy living or get busy dying"
Bilal135 Posted May 24, 2015 Author Posted May 24, 2015 Any help regarding it? "Get busy living or get busy dying"
xeon17 Posted May 24, 2015 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) A unique GangWar gamemode waiting for you!Click here for more information.
WhoAmI Posted May 24, 2015 Posted May 24, 2015 triggerServerEvent("pershingsquarespawn", localPlayer) Show your "pershingsquarespawn" event. You have to insert there setting skin's model. Not in client-side.
Bilal135 Posted May 24, 2015 Author 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. "Get busy living or get busy dying"
Bilal135 Posted May 24, 2015 Author 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 ) "Get busy living or get busy dying"
Walid Posted May 24, 2015 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) Do not yield your back to your enemy, might feel something strange in your ass. Two things are infinite the universe and human stupidity and i'm not sure about the universe. UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators
Bilal135 Posted May 24, 2015 Author Posted May 24, 2015 It still doesn't set the skin, no errors in debug. "Get busy living or get busy dying"
Mr_Moose Posted May 24, 2015 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. MTA Community | GitHub | 99Stack Forum
Bilal135 Posted May 24, 2015 Author 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! "Get busy living or get busy dying"
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