iPrestege Posted February 16, 2013 Share Posted February 16, 2013 Use This @ Server Side Sorry addEvent("onClick", true) addEventHandler("onClick", root, function(id) setElementModel(source,tonumber(id)) end ) addEventHandler("onPlayerLogin", root, function () triggerClientEvent(source,"show",source) end) Link to comment
Shazzimal Posted February 16, 2013 Author Share Posted February 16, 2013 @Mr.Pres[T]ege The script works well, i added something, so when you click te select button, the window will also get away. Now i added a 2nd button, when you click on it, it will preview the skin, this is the new code. ===Server-side=== addEvent("onClick", true) addEventHandler("onClick", root, function(id) setElementModel(source,tonumber(id)) end ) addEvent("onClick[2]", true) addEventHandler("onClick[2]", root, function(id) setElementModel(source,tonumber(id)) end ) addEventHandler("onPlayerLogin", root, function () triggerClientEvent(source,"show",root) end) addEventHandler("onPlayerWasted", root, function () triggerClientEvent(source,"show",root) end) ===Client-side=== GUIEditor = { gridlist = {}, button = {}, memo = {}, window = {}, } GUIEditor.window[1] = guiCreateWindow(387, 207, 243, 312, "Select a skin please", false) guiSetVisible(GUIEditor.window[1], false) guiWindowSetSizable(GUIEditor.window[1], false) GUIEditor.gridlist[1] = guiCreateGridList(9, 25, 135, 269, false, GUIEditor.window[1]) local Column = guiGridListAddColumn(GUIEditor.gridlist[1], "Skin Name", 0.4) local Column1 = guiGridListAddColumn(GUIEditor.gridlist[1], "id", 0.4) GUIEditor.button[2] = guiCreateButton(156, 31, 77, 26, "Preview", false, GUIEditor.window[1]) guiSetProperty(GUIEditor.button[2], "NormalTextColour", "FFAAAAAA") GUIEditor.button[1] = guiCreateButton(153, 251, 77, 26, "Select", false, GUIEditor.window[1]) guiSetProperty(GUIEditor.button[1], "NormalTextColour", "FFAAAAAA") GUIEditor.memo[1] = guiCreateMemo(155, 66, 73, 127, "You can change the skin, when you login and when you die.", false, GUIEditor.window[1]) Skins = { {"CJ",0}, {"Hooker",178}, {"Firefighter",277}, {"Gangster",115}, {"SchoolGirl",152}, {"Ninja",204}, {"Mafia",166}, {"Farmer",161}, {"Chicken",167}, {"Elvis",82} } for i,v in ipairs (Skins) do local row = guiGridListAddRow (GUIEditor.gridlist[1]) guiGridListSetItemText (GUIEditor.gridlist[1], row, 1, v[1], false, true) guiGridListSetItemText (GUIEditor.gridlist[1], row, 2, v[2], false, true) end addEventHandler("onClientGUIClick[2]",root, function() if (source == GUIEditor.button[2]) then local row,Column = guiGridListGetSelectedItem ( GUIEditor.gridlist[1] ) local id = tostring ( guiGridListGetItemText(GUIEditor.gridlist[1], row, 2 )) if ( row and Column and row ~= -1 and Column ~= -1 ) then triggerServerEvent("onClick[2]", localPlayer, id) end end end ) addEventHandler("onClientGUIClick",root, function() if (source == GUIEditor.button[1]) then local row,Column = guiGridListGetSelectedItem ( GUIEditor.gridlist[1] ) local id = tostring ( guiGridListGetItemText(GUIEditor.gridlist[1], row, 2 )) if ( row and Column and row ~= -1 and Column ~= -1 ) then triggerServerEvent("onClick", localPlayer, id) guiSetVisible(GUIEditor.window[1], false) showCursor(false) end end end ) addEvent("show",true) addEventHandler("show",root, function () guiSetVisible(GUIEditor.window[1], true) showCursor(true) end) But now when i click the "preview" button, nothing will happen, how can i fix this? Link to comment
iPrestege Posted February 16, 2013 Share Posted February 16, 2013 == Client Side == GUIEditor = { gridlist = {}, button = {}, memo = {}, window = {}, } GUIEditor.window[1] = guiCreateWindow(387, 207, 243, 312, "Select a skin please", false) guiSetVisible(GUIEditor.window[1], false) guiWindowSetSizable(GUIEditor.window[1], false) GUIEditor.gridlist[1] = guiCreateGridList(9, 25, 135, 269, false, GUIEditor.window[1]) local Column = guiGridListAddColumn(GUIEditor.gridlist[1], "Skin Name", 0.4) local Column1 = guiGridListAddColumn(GUIEditor.gridlist[1], "id", 0.4) GUIEditor.button[2] = guiCreateButton(156, 31, 77, 26, "Preview", false, GUIEditor.window[1]) guiSetProperty(GUIEditor.button[2], "NormalTextColour", "FFAAAAAA") GUIEditor.button[1] = guiCreateButton(153, 251, 77, 26, "Select", false, GUIEditor.window[1]) guiSetProperty(GUIEditor.button[1], "NormalTextColour", "FFAAAAAA") GUIEditor.memo[1] = guiCreateMemo(155, 66, 73, 127, "You can change the skin, when you login and when you die.", false, GUIEditor.window[1]) Skins = { {"CJ",0}, {"Hooker",178}, {"Firefighter",277}, {"Gangster",115}, {"SchoolGirl",152}, {"Ninja",204}, {"Mafia",166}, {"Farmer",161}, {"Chicken",167}, {"Elvis",82} } for i,v in ipairs (Skins) do local row = guiGridListAddRow (GUIEditor.gridlist[1]) guiGridListSetItemText (GUIEditor.gridlist[1], row, 1, v[1], false, true) guiGridListSetItemText (GUIEditor.gridlist[1], row, 2, v[2], false, true) end addEventHandler("onClientGUIClick",root, function() if (source == GUIEditor.button[2]) then local row,Column = guiGridListGetSelectedItem ( GUIEditor.gridlist[1] ) local id = tostring ( guiGridListGetItemText(GUIEditor.gridlist[1], row, 2 )) if ( row and Column and row ~= -1 and Column ~= -1 ) then triggerServerEvent("onClick[2]", localPlayer, id) end end end ) addEventHandler("onClientGUIClick",root, function() if (source == GUIEditor.button[1]) then local row,Column = guiGridListGetSelectedItem ( GUIEditor.gridlist[1] ) local id = tostring ( guiGridListGetItemText(GUIEditor.gridlist[1], row, 2 )) if ( row and Column and row ~= -1 and Column ~= -1 ) then triggerServerEvent("onClick", localPlayer, id) guiSetVisible(GUIEditor.window[1], false) showCursor(false) end end end ) addEvent("show",true) addEventHandler("show",root, function () guiSetVisible(GUIEditor.window[1], true) showCursor(true) end) You don,t have to change event name onClientGUIClick and onClientGUIClick[2] make no sense . Link to comment
Shazzimal Posted February 16, 2013 Author Share Posted February 16, 2013 Thanks, it worked!!! Link to comment
Shazzimal Posted February 16, 2013 Author Share Posted February 16, 2013 But this still not work? function setAdminSkin() if hasObjectPermissionTo(source, "command.ban", true) then setElementModel(source,268) outputChatBox("Welcome admin, your skin has been set to: Admin server skin.",source,255,0,0) end end Link to comment
iPrestege Posted February 16, 2013 Share Posted February 16, 2013 But this still not work? function setAdminSkin() if hasObjectPermissionTo(source, "command.ban", true) then setElementModel(source,268) outputChatBox("Welcome admin, your skin has been set to: Admin server skin.",source,255,0,0) end end When you want to happen when admin log in? Link to comment
Shazzimal Posted February 16, 2013 Author Share Posted February 16, 2013 when they login and when they die, so i must add a EventHandler, isn't it? Link to comment
iPrestege Posted February 16, 2013 Share Posted February 16, 2013 Yes That Right Add EventHandler "onPlayerLogin" , "onPlayerWasted" Link to comment
Shazzimal Posted February 16, 2013 Author Share Posted February 16, 2013 Yes, i know. Link to comment
Shazzimal Posted February 16, 2013 Author Share Posted February 16, 2013 I tried to add something, so the gui does only showup on a non-admin player. It doesn't work, i tried to add this function: hasObjectPermissionTo on this: addEvent("show",true) addEventHandler("show",root, function () guiSetVisible(GUIEditor.window[1], true) showCursor(true) end) How must i get it to work. Link to comment
iPrestege Posted February 16, 2013 Share Posted February 16, 2013 I tried to add something, so the gui does only showup on a non-admin player.It doesn't work, i tried to add this function: hasObjectPermissionTo on this: addEvent("show",true) addEventHandler("show",root, function () guiSetVisible(GUIEditor.window[1], true) showCursor(true) end) How must i get it to work. You Want The GUI For Admin Only ? Link to comment
Shazzimal Posted February 16, 2013 Author Share Posted February 16, 2013 the gui for players only Link to comment
iPrestege Posted February 16, 2013 Share Posted February 16, 2013 the gui for players only yes i know that! you want it for admin only? Link to comment
Mega9 Posted February 16, 2013 Share Posted February 16, 2013 function setAdminSkin() if hasObjectPermissionTo(thePlayer, "command.ban", true) then setPlayerSkin(thePlayer, 286) outputChatBox("Welcome admin, your skin has been set to: Admin server skin.",thePlayer) end end When do you trigger this function? Link to comment
Shazzimal Posted February 16, 2013 Author Share Posted February 16, 2013 function setAdminSkin() if hasObjectPermissionTo(thePlayer, "command.ban", true) then setPlayerSkin(thePlayer, 286) outputChatBox("Welcome admin, your skin has been set to: Admin server skin.",thePlayer) end end When do you trigger this function? A bit late, it's almost fixed. Link to comment
iPrestege Posted February 16, 2013 Share Posted February 16, 2013 So You Want It For Admin Only I Mean The GUI ? Link to comment
Mega9 Posted February 16, 2013 Share Posted February 16, 2013 Oh am I freaking blind, I've seen only the first page of this topic. ROFL Nvm then, sorry for interrupting. Link to comment
Shazzimal Posted February 16, 2013 Author Share Posted February 16, 2013 So You Want It For Admin Only I Mean The GUI ? I want the GUI for non-admins. For this: addEventHandler("onPlayerSpawn", root, function () if hasObjectPermissionTo(source, "command.ban", true) then setElementModel(source,286) outputChatBox("Welcome admin, your skin has been set to: Admin server skin.",source,255,0,0) end end) It will not give me the skin i want, everytime i die and get alive, i will get another skin, not ID 286. Link to comment
iPrestege Posted February 16, 2013 Share Posted February 16, 2013 addEventHandler("onPlayerSpawn", root, function () if hasObjectPermissionTo(source, "command.ban", true) then setElementModel(source,math.random (1,400)) outputChatBox("Welcome admin, your skin has been set to: Admin server skin.",source,255,0,0) end end) Link to comment
Shazzimal Posted February 16, 2013 Author Share Posted February 16, 2013 addEventHandler("onPlayerSpawn", root, function () if hasObjectPermissionTo(source, "command.ban", true) then setElementModel(source,math.random (1,400)) outputChatBox("Welcome admin, your skin has been set to: Admin server skin.",source,255,0,0) end end) That's not what i mean, i mean that i will not get the skin i want, when i get alive, after i died. How can i fix it. ===server-side=== addEventHandler("onPlayerSpawn", root, function () if hasObjectPermissionTo(source, "command.ban", true) then setElementModel(source,286) outputChatBox("Welcome admin, your skin has been set to: Admin server skin.",source,255,0,0) end end) Link to comment
iPrestege Posted February 16, 2013 Share Posted February 16, 2013 So How We Will Do it you want it on spawn and wasted realy i don't know how will do it . Link to comment
Shazzimal Posted February 16, 2013 Author Share Posted February 16, 2013 I want that when you die as admin, and than when you spawn back, you will get skin ID 286 Link to comment
iPrestege Posted February 16, 2013 Share Posted February 16, 2013 and if he die how you will see the skin ? just that make no sense at all . 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