Evil-Cod3r Posted January 31, 2012 Share Posted January 31, 2012 Hi i have Select Weapons But every Time i died the Weapons Panel Show again i want if he Select His Weapons Save it and if he died the Weapons He Select return to him with out show the Panel lp = getLocalPlayer() rRoot = getResourceRootElement(getThisResource()) addEventHandler("onClientResourceStart",rRoot,function() triggerServerEvent("getData",lp,lp) end ) addEvent("sendData",true) addEventHandler("sendData",root,function(small,med,misc) if small and med and misc then smallGuns = small mediumGuns = med miscGuns = misc WCW = guiCreateWindow(367,244,570,233,"Please Choose Weapon",false) guiSetVisible (WCW, false) guiWindowSetSizable(WCW,false) guiWindowSetMovable(WCW,false) local screenW,screenH=guiGetScreenSize() local windowW,windowH=guiGetSize(WCW,false) local x,y = (screenW-windowW)/2,(screenH-windowH)/2 guiSetPosition(WCW,x,y,false) ButOK = guiCreateButton(18,207,256,19,"OK",false,WCW) ButC = guiCreateButton(290,207,256,19,"Cancel",false,WCW) guiBringToFront(ButC) guiBringToFront(ButOK) WCSmallGuns = guiCreateGridList(18,54,169,148,false,WCW) guiGridListSetSelectionMode(WCSmallGuns,0) local columnSG = guiGridListAddColumn( WCSmallGuns, "Small Guns", 0.55 ) local ammoSG = guiGridListAddColumn( WCSmallGuns, "Ammo", 0.20 ) if ( columnSG ) then for k,v in ipairs (smallGuns) do local jSG = guiGridListAddRow ( WCSmallGuns ) guiGridListSetItemText ( WCSmallGuns, jSG, columnSG,getWeaponNameFromID(v[1]), false, false ) guiGridListSetItemText ( WCSmallGuns, jSG, ammoSG,v[2], false, true ) end end WCMGuns = guiCreateGridList(198,53,169,148,false,WCW) guiGridListSetSelectionMode(WCMGuns,0) local columnMG = guiGridListAddColumn( WCMGuns, "Medium Guns", 0.55 ) local ammoMG = guiGridListAddColumn( WCMGuns, "Ammo", 0.20 ) if ( columnMG ) then for k,v in ipairs (mediumGuns) do local jSG = guiGridListAddRow ( WCMGuns ) guiGridListSetItemText ( WCMGuns, jSG, columnMG,getWeaponNameFromID(v[1]), false, false ) guiGridListSetItemText ( WCMGuns, jSG, ammoMG,v[2], false, true ) end end WCMiscGuns = guiCreateGridList(378,52,169,148,false,WCW) guiGridListSetSelectionMode(WCMiscGuns,0) local columnMSG = guiGridListAddColumn( WCMiscGuns, "Misc. Guns", 0.55 ) local ammoMSG = guiGridListAddColumn( WCMiscGuns, "Ammo", 0.20 ) if ( columnMSG ) then for k,v in ipairs (miscGuns) do local jSG = guiGridListAddRow ( WCMiscGuns ) guiGridListSetItemText ( WCMiscGuns, jSG, columnMSG,getWeaponNameFromID(v[1]), false, false ) guiGridListSetItemText ( WCMiscGuns, jSG, ammoMSG,v[2], false, true ) end end function ShowWC() getVisible = guiGetVisible (WCW) if (getVisible == true) then guiSetVisible (WCW , false) guiSetVisible (ButOK , false) guiSetVisible (ButC , false) showCursor (false) end if (getVisible == false) then guiSetVisible (WCW , true) guiSetVisible (ButOK , true) guiSetVisible (ButC , true) showCursor (true) end end addEvent("ShowWC",true) addEventHandler("ShowWC",root,ShowWC) function onClick (button, state, absoluteX, absoluteY) if ( source == ButOK ) then triggerServerEvent("TakeAll",lp,lp) wep = guiGridListGetItemText (WCSmallGuns, guiGridListGetSelectedItem (WCSmallGuns), 1) ammo = guiGridListGetItemText (WCSmallGuns, guiGridListGetSelectedItem (WCSmallGuns), 2) if wep and ammo then triggerServerEvent("GiveGun",lp,lp,getWeaponIDFromName(wep),ammo) end wep = guiGridListGetItemText (WCMGuns, guiGridListGetSelectedItem (WCMGuns), 1) ammo = guiGridListGetItemText (WCMGuns, guiGridListGetSelectedItem (WCMGuns), 2) if wep and ammo then triggerServerEvent("GiveGun",lp,lp,getWeaponIDFromName(wep),ammo) end wep = guiGridListGetItemText (WCMiscGuns, guiGridListGetSelectedItem (WCMiscGuns), 1) ammo = guiGridListGetItemText (WCMiscGuns, guiGridListGetSelectedItem (WCMiscGuns), 2) if wep and ammo then triggerServerEvent("GiveGun",lp,lp,getWeaponIDFromName(wep),ammo) end ShowWC() elseif ( source == ButC ) then ShowWC() end end addEventHandler ("onClientGUIClick", getRootElement(), onClick) end end ) setTimer(fileDelete,1000,1,"WC-C.lua") function getData(to) local file = xmlLoadFile("data.xml") small = {} med = {} misc = {} if file then for k,v in ipairs (xmlNodeGetChildren(xmlFindChild(file,"SmallGuns",0)))do local id = xmlNodeGetAttribute(v,"id") local ammo = xmlNodeGetAttribute(v,"ammo") table.insert(small, {id,ammo}) end for k,v in ipairs (xmlNodeGetChildren(xmlFindChild(file,"MediumGuns",0)))do local id = xmlNodeGetAttribute(v,"id") local ammo = xmlNodeGetAttribute(v,"ammo") table.insert(med, {id,ammo}) end for k,v in ipairs (xmlNodeGetChildren(xmlFindChild(file,"MiscGuns",0)))do local id = xmlNodeGetAttribute(v,"id") local ammo = xmlNodeGetAttribute(v,"ammo") table.insert(misc, {id,ammo}) end end triggerClientEvent(to,"sendData",to,small,med,misc) end addEvent("getData",true) addEventHandler("getData",root,getData) function TakeAll( Player ) takeAllWeapons(Player) end addEvent("TakeAll",true) addEventHandler("TakeAll",getRootElement(),TakeAll) function GiveGun( Player , Gun , Ammo ) if Gun and Ammo then giveWeapon(Player, Gun,Ammo) setPedWeaponSlot(Player, getSlotFromWeapon(Gun)) end end addEvent("GiveGun",true) addEventHandler("GiveGun",getRootElement(),GiveGun) function ShowWC(Player) triggerClientEvent(Player,"ShowWC",Player) end addEventHandler("onPlayerSpawn",root,function() ShowWC(source) addCommandHandler("gun",function(plr) ShowWC(plr) end ) setTimer(removeCommandHandler,1 * 60 * 1000 ,1, "gun") end) Link to comment
Evil-Cod3r Posted January 31, 2012 Author Share Posted January 31, 2012 Some One Please Link to comment
TAPL Posted January 31, 2012 Share Posted January 31, 2012 lp = getLocalPlayer() rRoot = getResourceRootElement(getThisResource()) addEventHandler("onClientResourceStart",rRoot,function() triggerServerEvent("getData",lp,lp) end ) addEvent("sendData",true) addEventHandler("sendData",root,function(small,med,misc) if small and med and misc then smallGuns = small mediumGuns = med miscGuns = misc WCW = guiCreateWindow(367,244,570,233,"Please Choose Weapon",false) guiSetVisible (WCW, false) guiWindowSetSizable(WCW,false) guiWindowSetMovable(WCW,false) local screenW,screenH=guiGetScreenSize() local windowW,windowH=guiGetSize(WCW,false) local x,y = (screenW-windowW)/2,(screenH-windowH)/2 guiSetPosition(WCW,x,y,false) ButOK = guiCreateButton(18,207,256,19,"OK",false,WCW) ButC = guiCreateButton(290,207,256,19,"Cancel",false,WCW) checkBox = guiCreateCheckBox(20,30,150,20,"Show This Menu again?",true,false,WCW) guiBringToFront(ButC) guiBringToFront(ButOK) function checkboxClick() if (guiCheckBoxGetSelected(checkBox) ) then setElementData(localPlayer,"ShowGun",false) else setElementData(localPlayer,"ShowGun",true) end end addEventHandler("onClientGUIClick", checkBox, checkboxClick, false) WCSmallGuns = guiCreateGridList(18,54,169,148,false,WCW) guiGridListSetSelectionMode(WCSmallGuns,0) local columnSG = guiGridListAddColumn( WCSmallGuns, "Small Guns", 0.55 ) local ammoSG = guiGridListAddColumn( WCSmallGuns, "Ammo", 0.20 ) if ( columnSG ) then for k,v in ipairs (smallGuns) do local jSG = guiGridListAddRow ( WCSmallGuns ) guiGridListSetItemText ( WCSmallGuns, jSG, columnSG,getWeaponNameFromID(v[1]), false, false ) guiGridListSetItemText ( WCSmallGuns, jSG, ammoSG,v[2], false, true ) end end WCMGuns = guiCreateGridList(198,53,169,148,false,WCW) guiGridListSetSelectionMode(WCMGuns,0) local columnMG = guiGridListAddColumn( WCMGuns, "Medium Guns", 0.55 ) local ammoMG = guiGridListAddColumn( WCMGuns, "Ammo", 0.20 ) if ( columnMG ) then for k,v in ipairs (mediumGuns) do local jSG = guiGridListAddRow ( WCMGuns ) guiGridListSetItemText ( WCMGuns, jSG, columnMG,getWeaponNameFromID(v[1]), false, false ) guiGridListSetItemText ( WCMGuns, jSG, ammoMG,v[2], false, true ) end end WCMiscGuns = guiCreateGridList(378,52,169,148,false,WCW) guiGridListSetSelectionMode(WCMiscGuns,0) local columnMSG = guiGridListAddColumn( WCMiscGuns, "Misc. Guns", 0.55 ) local ammoMSG = guiGridListAddColumn( WCMiscGuns, "Ammo", 0.20 ) if ( columnMSG ) then for k,v in ipairs (miscGuns) do local jSG = guiGridListAddRow ( WCMiscGuns ) guiGridListSetItemText ( WCMiscGuns, jSG, columnMSG,getWeaponNameFromID(v[1]), false, false ) guiGridListSetItemText ( WCMiscGuns, jSG, ammoMSG,v[2], false, true ) end end function ShowWC() getVisible = guiGetVisible (WCW) if (getVisible == true) then guiSetVisible (WCW , false) guiSetVisible (ButOK , false) guiSetVisible (ButC , false) showCursor (false) end if (getVisible == false) then guiSetVisible (WCW , true) guiSetVisible (ButOK , true) guiSetVisible (ButC , true) showCursor (true) end end addEvent("ShowWC",true) addEventHandler("ShowWC",root,ShowWC) function onClick (button, state, absoluteX, absoluteY) if ( source == ButOK ) then triggerServerEvent("TakeAll",lp,lp) wep = guiGridListGetItemText (WCSmallGuns, guiGridListGetSelectedItem (WCSmallGuns), 1) ammo = guiGridListGetItemText (WCSmallGuns, guiGridListGetSelectedItem (WCSmallGuns), 2) if wep and ammo then triggerServerEvent("GiveGun",lp,lp,getWeaponIDFromName(wep),ammo) end wep = guiGridListGetItemText (WCMGuns, guiGridListGetSelectedItem (WCMGuns), 1) ammo = guiGridListGetItemText (WCMGuns, guiGridListGetSelectedItem (WCMGuns), 2) if wep and ammo then triggerServerEvent("GiveGun",lp,lp,getWeaponIDFromName(wep),ammo) end wep = guiGridListGetItemText (WCMiscGuns, guiGridListGetSelectedItem (WCMiscGuns), 1) ammo = guiGridListGetItemText (WCMiscGuns, guiGridListGetSelectedItem (WCMiscGuns), 2) if wep and ammo then triggerServerEvent("GiveGun",lp,lp,getWeaponIDFromName(wep),ammo) end ShowWC() elseif ( source == ButC ) then ShowWC() end end addEventHandler ("onClientGUIClick", getRootElement(), onClick) end end ) function getData(to) local file = xmlLoadFile("data.xml") small = {} med = {} misc = {} if file then for k,v in ipairs (xmlNodeGetChildren(xmlFindChild(file,"SmallGuns",0)))do local id = xmlNodeGetAttribute(v,"id") local ammo = xmlNodeGetAttribute(v,"ammo") table.insert(small, {id,ammo}) end for k,v in ipairs (xmlNodeGetChildren(xmlFindChild(file,"MediumGuns",0)))do local id = xmlNodeGetAttribute(v,"id") local ammo = xmlNodeGetAttribute(v,"ammo") table.insert(med, {id,ammo}) end for k,v in ipairs (xmlNodeGetChildren(xmlFindChild(file,"MiscGuns",0)))do local id = xmlNodeGetAttribute(v,"id") local ammo = xmlNodeGetAttribute(v,"ammo") table.insert(misc, {id,ammo}) end end triggerClientEvent(to,"sendData",to,small,med,misc) end addEvent("getData",true) addEventHandler("getData",root,getData) function TakeAll( Player ) takeAllWeapons(Player) end addEvent("TakeAll",true) addEventHandler("TakeAll",getRootElement(),TakeAll) function GiveGun( Player , Gun , Ammo ) if Gun and Ammo then giveWeapon(Player, Gun,Ammo) setPedWeaponSlot(Player, getSlotFromWeapon(Gun)) end end addEvent("GiveGun",true) addEventHandler("GiveGun",getRootElement(),GiveGun) function ShowWC(Player) triggerClientEvent(Player,"ShowWC",Player) end addEventHandler("onPlayerSpawn",root,function() if not getElementData(source,"ShowGun") then ShowWC(source) end addCommandHandler("gun",function(plr) ShowWC(plr) end ) setTimer(removeCommandHandler,1 * 60 * 1000 ,1, "gun") end) Link to comment
Evil-Cod3r Posted January 31, 2012 Author Share Posted January 31, 2012 The Hide Work But when i died dosnt give me any weapons Link to comment
Evil-Cod3r Posted January 31, 2012 Author Share Posted January 31, 2012 Please Help Me TApl Link to comment
TAPL Posted January 31, 2012 Share Posted January 31, 2012 (edited) this really easy Edit: i change the code, copy it again lp = getLocalPlayer() rRoot = getResourceRootElement(getThisResource()) addEventHandler("onClientResourceStart",rRoot,function() triggerServerEvent("getData",lp,lp) end ) addEvent("sendData",true) addEventHandler("sendData",root,function(small,med,misc) if small and med and misc then smallGuns = small mediumGuns = med miscGuns = misc WCW = guiCreateWindow(367,244,570,233,"Please Choose Weapon",false) guiSetVisible (WCW, false) guiWindowSetSizable(WCW,false) guiWindowSetMovable(WCW,false) local screenW,screenH=guiGetScreenSize() local windowW,windowH=guiGetSize(WCW,false) local x,y = (screenW-windowW)/2,(screenH-windowH)/2 guiSetPosition(WCW,x,y,false) ButOK = guiCreateButton(18,207,256,19,"OK",false,WCW) ButC = guiCreateButton(290,207,256,19,"Cancel",false,WCW) checkBox = guiCreateCheckBox(20,30,150,20,"Show This Menu again?",true,false,WCW) guiBringToFront(ButC) guiBringToFront(ButOK) function checkboxClick() if (guiCheckBoxGetSelected(checkBox) ) then setElementData(localPlayer,"ShowGun",false) else setElementData(localPlayer,"ShowGun",true) end end addEventHandler("onClientGUIClick", checkBox, checkboxClick, false) function GiveWeapon() triggerServerEvent("TakeAll",lp,lp) wep = guiGridListGetItemText (WCSmallGuns, guiGridListGetSelectedItem (WCSmallGuns), 1) ammo = guiGridListGetItemText (WCSmallGuns, guiGridListGetSelectedItem (WCSmallGuns), 2) if wep and ammo then triggerServerEvent("GiveGun",lp,lp,getWeaponIDFromName(wep),ammo) end wep = guiGridListGetItemText (WCMGuns, guiGridListGetSelectedItem (WCMGuns), 1) ammo = guiGridListGetItemText (WCMGuns, guiGridListGetSelectedItem (WCMGuns), 2) if wep and ammo then triggerServerEvent("GiveGun",lp,lp,getWeaponIDFromName(wep),ammo) end wep = guiGridListGetItemText (WCMiscGuns, guiGridListGetSelectedItem (WCMiscGuns), 1) ammo = guiGridListGetItemText (WCMiscGuns, guiGridListGetSelectedItem (WCMiscGuns), 2) if wep and ammo then triggerServerEvent("GiveGun",lp,lp,getWeaponIDFromName(wep),ammo) end end addEvent("GiveGunMenu",true) addEventHandler("GiveGunMenu",root,GiveWeapon) WCSmallGuns = guiCreateGridList(18,54,169,148,false,WCW) guiGridListSetSelectionMode(WCSmallGuns,0) local columnSG = guiGridListAddColumn( WCSmallGuns, "Small Guns", 0.55 ) local ammoSG = guiGridListAddColumn( WCSmallGuns, "Ammo", 0.20 ) if ( columnSG ) then for k,v in ipairs (smallGuns) do local jSG = guiGridListAddRow ( WCSmallGuns ) guiGridListSetItemText ( WCSmallGuns, jSG, columnSG,getWeaponNameFromID(v[1]), false, false ) guiGridListSetItemText ( WCSmallGuns, jSG, ammoSG,v[2], false, true ) end end WCMGuns = guiCreateGridList(198,53,169,148,false,WCW) guiGridListSetSelectionMode(WCMGuns,0) local columnMG = guiGridListAddColumn( WCMGuns, "Medium Guns", 0.55 ) local ammoMG = guiGridListAddColumn( WCMGuns, "Ammo", 0.20 ) if ( columnMG ) then for k,v in ipairs (mediumGuns) do local jSG = guiGridListAddRow ( WCMGuns ) guiGridListSetItemText ( WCMGuns, jSG, columnMG,getWeaponNameFromID(v[1]), false, false ) guiGridListSetItemText ( WCMGuns, jSG, ammoMG,v[2], false, true ) end end WCMiscGuns = guiCreateGridList(378,52,169,148,false,WCW) guiGridListSetSelectionMode(WCMiscGuns,0) local columnMSG = guiGridListAddColumn( WCMiscGuns, "Misc. Guns", 0.55 ) local ammoMSG = guiGridListAddColumn( WCMiscGuns, "Ammo", 0.20 ) if ( columnMSG ) then for k,v in ipairs (miscGuns) do local jSG = guiGridListAddRow ( WCMiscGuns ) guiGridListSetItemText ( WCMiscGuns, jSG, columnMSG,getWeaponNameFromID(v[1]), false, false ) guiGridListSetItemText ( WCMiscGuns, jSG, ammoMSG,v[2], false, true ) end end function ShowWC() getVisible = guiGetVisible (WCW) if (getVisible == true) then guiSetVisible (WCW , false) guiSetVisible (ButOK , false) guiSetVisible (ButC , false) showCursor (false) end if (getVisible == false) then guiSetVisible (WCW , true) guiSetVisible (ButOK , true) guiSetVisible (ButC , true) showCursor (true) end end addEvent("ShowWC",true) addEventHandler("ShowWC",root,ShowWC) function onClick (button, state, absoluteX, absoluteY) if ( source == ButOK ) then triggerServerEvent("TakeAll",lp,lp) wep = guiGridListGetItemText (WCSmallGuns, guiGridListGetSelectedItem (WCSmallGuns), 1) ammo = guiGridListGetItemText (WCSmallGuns, guiGridListGetSelectedItem (WCSmallGuns), 2) if wep and ammo then triggerServerEvent("GiveGun",lp,lp,getWeaponIDFromName(wep),ammo) end wep = guiGridListGetItemText (WCMGuns, guiGridListGetSelectedItem (WCMGuns), 1) ammo = guiGridListGetItemText (WCMGuns, guiGridListGetSelectedItem (WCMGuns), 2) if wep and ammo then triggerServerEvent("GiveGun",lp,lp,getWeaponIDFromName(wep),ammo) end wep = guiGridListGetItemText (WCMiscGuns, guiGridListGetSelectedItem (WCMiscGuns), 1) ammo = guiGridListGetItemText (WCMiscGuns, guiGridListGetSelectedItem (WCMiscGuns), 2) if wep and ammo then triggerServerEvent("GiveGun",lp,lp,getWeaponIDFromName(wep),ammo) end ShowWC() elseif ( source == ButC ) then ShowWC() end end addEventHandler ("onClientGUIClick", getRootElement(), onClick) end end ) function getData(to) local file = xmlLoadFile("data.xml") small = {} med = {} misc = {} if file then for k,v in ipairs (xmlNodeGetChildren(xmlFindChild(file,"SmallGuns",0)))do local id = xmlNodeGetAttribute(v,"id") local ammo = xmlNodeGetAttribute(v,"ammo") table.insert(small, {id,ammo}) end for k,v in ipairs (xmlNodeGetChildren(xmlFindChild(file,"MediumGuns",0)))do local id = xmlNodeGetAttribute(v,"id") local ammo = xmlNodeGetAttribute(v,"ammo") table.insert(med, {id,ammo}) end for k,v in ipairs (xmlNodeGetChildren(xmlFindChild(file,"MiscGuns",0)))do local id = xmlNodeGetAttribute(v,"id") local ammo = xmlNodeGetAttribute(v,"ammo") table.insert(misc, {id,ammo}) end end triggerClientEvent(to,"sendData",to,small,med,misc) end addEvent("getData",true) addEventHandler("getData",root,getData) function TakeAll( Player ) takeAllWeapons(Player) end addEvent("TakeAll",true) addEventHandler("TakeAll",getRootElement(),TakeAll) function GiveGun( Player , Gun , Ammo ) if Gun and Ammo then giveWeapon(Player, Gun,Ammo) setPedWeaponSlot(Player, getSlotFromWeapon(Gun)) end end addEvent("GiveGun",true) addEventHandler("GiveGun",getRootElement(),GiveGun) function ShowWC(Player) triggerClientEvent(Player,"ShowWC",Player) end addEventHandler("onPlayerSpawn",root,function() if not getElementData(source,"ShowGun") then ShowWC(source) else triggerClientEvent(source,"GiveGunMenu",source) end addCommandHandler("gun",function(plr) ShowWC(plr) end ) setTimer(removeCommandHandler,1 * 60 * 1000 ,1, "gun") end) Edited January 31, 2012 by Guest Link to comment
Evil-Cod3r Posted January 31, 2012 Author Share Posted January 31, 2012 Thx Tapl work 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