CeKiT Posted November 2, 2012 Share Posted November 2, 2012 Hola Amigos! Tengo este script que saque de un buy panel map. --Some vars --Author TwiX [[Don't Remove This Line]] local sW,sH = guiGetScreenSize(); local gUtils = {}; gUtils.guiW,gUtils.guiH = 398,341; gUtils.posX,gUtils.posY = sW/2-gUtils.guiW/2,sH/2-gUtils.guiH/2; --Center of screen for all resolutions local gLabels = {}; function onresourceStart() gWindow = guiCreateWindow(gUtils.posX,gUtils.posY,gUtils.guiW,gUtils.guiH,"Mini Map Shop v0.2",false); gLabels[1] = guiCreateLabel(206,30,161,19,"Money:",false,gWindow); gLabels[2] = guiCreateLabel(206,49,100,16,"A Map Costs 5000$",false,gWindow); gLabels[3] = guiCreateLabel(206,66,82,15,"Selected Map:",false,gWindow); gLabels[4] = guiCreateLabel(206,106,188,22,"Buy Maps Shop by TwiX",false,gWindow); gLabels[5] = guiCreateLabel(206,125,67,22,"Search Map:",false,gWindow); gUtils[1] = guiCreateLabel(206,86,188,16,"Please select any map",false,gWindow); guiLabelSetColor(gUtils[1],171,205,239) for _,label in ipairs (gLabels) do guiSetFont(label,"default-bold-small"); if label == gLabels[3] then guiLabelSetColor(gLabels[3],0,255,0); end end gButton = guiCreateButton(207,291,182,35,"Buy as next map",false,gWindow); gGridList = guiCreateGridList(11,32,191,395,false,gWindow); guiGridListSetSelectionMode(gGridList,2); gColumn = guiGridListAddColumn(gGridList,"Name:",0.85); guiWindowSetSizable(gWindow,false) pEdit = guiCreateEdit(206,145,153,26,"",false,gWindow); guiSetVisible (gWindow,false); addEventHandler ("onClientGUIClick",getResourceRootElement(getThisResource()),somethingFromClick); bindKey ("F1","down",showPanel); end addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()),onresourceStart) function showPanel() if guiGetVisible(gWindow) then guiSetVisible(gWindow,false); showCursor(false); removeEventHandler("onClientGUIChanged",pEdit,startSearchMap); else triggerServerEvent("doRefreshMapList",localPlayer,localPlayer); addEventHandler("onClientGUIChanged",pEdit,startSearchMap); guiSetVisible(gWindow,true); showCursor(true); local playerMoney = getPlayerMoney(); guiSetText(gLabels[1],"Money: [ "..playerMoney.." ]"); end end function somethingFromClick(button,state) if source == gButton then local row = guiGridListGetSelectedItem(gGridList); local mapName = guiGridListGetItemText(gGridList,row,gColumn); triggerServerEvent("doBuyMap",localPlayer,localPlayer,mapName); elseif source == gGridList then local selectedMap = guiGridListGetSelectedItem(gGridList); local row = guiGridListGetSelectedItem(gGridList); local mapName = guiGridListGetItemText(gGridList,row,gColumn); if selectedMap == -1 then guiSetText(gUtils[1],"Error! Please Select any map"); return end guiSetText(gUtils[1],mapName); end end function setMapNameInGrid(gamemodeMapTable,gamemode,map,s) guiGridListClear(gGridList); if gamemodeMapTable then aGamemodeMapTable = gamemodeMapTable; for id,gamemode in pairs (gamemodeMapTable) do if (gamemode.name == "Race") then for id,map in ipairs (gamemode.maps) do if s then if string.find(string.lower(map.name),string.lower(s)) then local row = guiGridListAddRow (gGridList); guiGridListSetItemText(gGridList,row,gColumn,map.name,false,false); guiGridListSetItemData (gGridList,row,gColumn,map.resname); end else local row = guiGridListAddRow (gGridList); guiGridListSetItemText (gGridList,row,gColumn,map.name,false,false); guiGridListSetItemData (gGridList,row,gColumn,map.resname); end end end end end end addEvent("refreshCompleted",true) addEventHandler( "refreshCompleted",getRootElement(),setMapNameInGrid) function startSearchMap() if not source == pEdit then return end guiGridListClear(gGridList); if guiGetText(pEdit) ~= "" then local found = 0; for id,gamemode in pairs (aGamemodeMapTable) do if (gamemode.name == "Race") then for id,map in ipairs (gamemode.maps) do if string.find(string.lower(map.name),string.lower(guiGetText(pEdit):lower()),0,true) ~= nil then local row = guiGridListAddRow(gGridList); guiGridListSetItemText(gGridList,row,1,map.name,false,false); found = found + 1; end end end end if found == 0 then local row = guiGridListAddRow(gGridList); guiGridListSetItemText(gGridList,row,1,"Map not found",false,false); guiGridListSetItemColor(gGridList,row,1,255,0,0); end else for id,gamemode in pairs (aGamemodeMapTable) do if (gamemode.name == "Race") then for id,map in ipairs (gamemode.maps) do local row = guiGridListAddRow(gGridList); guiGridListSetItemText(gGridList,row,1,map.name,false,false); end end end end end fileDelete ('tx_mapsShop_c.lua') esto lo que hace es al seccionar el mapa le descuenta al jugador dinero y setea como nextmap el mapa que compro. Lo que yo necesito hacer es que cuando se seleccione un mapa en ves de setearlo y descontarle dinero, carge el mapa y lo lleve a ese mapa al usuario. Para que cada jugador pueda jugar el mapa que quiera. Me dijieron que tenia que cargarlos con loadstring y teleportarlo a diferentes dimensiones pero no se como hacerlo. Gracias Link to comment
CeKiT Posted November 3, 2012 Author Share Posted November 3, 2012 y que me recomiendan que lo mande a una de las 69.000 dimensiones que hay por math.random?, o elaboro otra forma para que vaya poniendo en distintas dimensiones pero que vaya progresivamente. Osea de 0 a 69.000, para que todos los mapas esten en distintas dimensiones. Link to comment
Recommended Posts