DRW Posted May 2, 2015 Posted May 2, 2015 I'm creating a scrpt that creates a marker and opens a GUI, when you press a button it will give you a random weapon with random ammo, how can I make the script to tell the weapon you received on the chatbox? Client rRoot = getResourceRootElement(getThisResource()) function cerrarmystery () guiSetVisible(mystery,false) showCursor (false) end local weapons = { 12, 14, 15, 20, 30, 31 } function abrirmystery () guiSetVisible (mystery, true) showCursor (true) end function mysterymoney (thePlayer) local money = getPlayerMoney(thePlayer) if (money < 8000) then outputChatBox ("NO TIENES SUFICIENTE DINERO") return else triggerServerEvent ("quitardinero",localPlayer) outputChatBox ("HAS COMPRADO LA CAJA MISTERIOSA") playSound ("mysbox.mp3",false) triggerServerEvent ("dararma", localPlayer) end end addEvent ("cajamisterio", true) addEventHandler ("cajamisterio", localPlayer, abrirmystery) addEventHandler ("onClientResourceStart", rRoot,cerrarmystery) local screenW, screenH = guiGetScreenSize() mystery = guiCreateWindow((screenW - 699) / 2, (screenH - 152) / 2, 699, 152, "CAJA MISTERIOSA", false) guiWindowSetSizable(mystery, false) mysterylabel = guiCreateLabel(55, 23, 592, 46, "¿Quieres comprar la caja aleatoria?", false, mystery) guiSetFont(mysterylabel, "sa-header") mysterybutton1 = guiCreateButton(460, 81, 187, 48, "NO.", false, mystery) guiSetFont(mysterybutton1, "default-bold-small") guiSetProperty(mysterybutton1, "NormalTextColour", "FFFF0000") mysterybutton2 = guiCreateButton(55, 81, 187, 48, "SÍ (8.000$)", false, mystery) guiSetFont(mysterybutton2, "default-bold-small") guiSetProperty(mysterybutton2, "NormalTextColour", "FF84FF00") addEventHandler ("onClientGUIClick", mysterybutton1, cerrarmystery, false) addEventHandler ("onClientGUIClick", mysterybutton2, mysterymoney, false) Server mysterymarker = createMarker (-514,2649,52.5, "cylinder", 2.0,255,255,255,255) local weapons = { 25,26,27,28,29,32,30,31,33,34,38,22,23,24,14,41,12,15} local ammo = {100,120,150,180,200,250,400,500,600,700,800,900,1000} function mysteriomarker (plr) if plr then triggerClientEvent(plr,"cajamisterio",plr) end end addEventHandler ("onMarkerHit", mysterymarker, mysteriomarker) function fueradinero () takePlayerMoney (source, 8000 ) end addEvent ("quitardinero",true) addEventHandler ("quitardinero", root, fueradinero) addEvent ("dararma",true) addEventHandler ("dararma", root, function () giveWeapon( source, weapons[ math.random( #weapons ) ] , ammo[math.random(#ammo)] , true) ; end ) Proud owner and developer of ZNEXT: Aftermath. Enter a post-apocalyptic San Andreas and fight over 30 types of enemies and bosses with varying difficulties and skills, improve and customize your character by leveling up, completing challenges and a solid lootbox system with no Pay-to-Win mechanics that will break your experience. Meet new characters, creatures and weapon metas, experience an innovative combo-based melee system, or join our solid PvP modes to show other survivors who’s boss. Español, Pусский, Türk, عربى, Polski, Português IP: mtasa://104.36.110.227:22003 - Discord: https://discord.gg/CxMxjvC5pB
Enargy, Posted May 2, 2015 Posted May 2, 2015 try this addEvent ("dararma",true) addEventHandler ("dararma", root, function () weapon, totalAmmo = weapons[ math.random( #weapons ) ] , ammo[math.random(#ammo)] weaponReceived = giveWeapon( source, weapon, totalAmmo, true); if weaponReceived then outputChatBox("you've received a '"..getPedWeapon ( source ).."' with '"..totalAmmo.."' ammo", source, 0, 255, 0); end end) - Inactivo.
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