surfer Posted July 2, 2012 Posted July 2, 2012 Acredito que não seja a especialidade de muitos aqui porém trago a vocês está duvida, já tentei de algumas maneiras fazer a função mencionada na race, porém sem sucesso addEvent("clientBuyMap", true ) addEventHandler("clientBuyMap", root, function(name) name = string.sub(name, 6) call(getResourceFromName("race"), "buyMap",source,name) end ) Tenho esta função, que está no script tipo server function buyMap() if (getElementData(me,"money") - 5000 ) >= 0 then local map = guiGetText(gui.mname) triggerServerEvent("clientBuyMap", me, map) else outputChatBox("[sHOP] #ffffffYou don't have enough money to a map! "..math.abs(getMoney() - 5000).."$ missing!", 255,150,150,true) end end esta no script client, e preciso fazer está que me falta na race, porém tentei faze-la desta maneira: addEvent("onExternalNextmapRequest", true) function externalNextmapRequest(thePlayer, mapName) local query = #{mapName}>0 and table.concat({mapName},' ') or nil local map, errormsg = findMap( query ) if not map then outputRace( errormsg, player ) return end g_ForcedNextMap = map triggerClientEvent ("setNextMap", getRootElement(), getMapName(map)) triggerEvent("onBuyMapSetStatus", getRootElement(), "true") triggerEvent("onScriptSetNextMap", thePlayer, mapName) end addEventHandler("onExternalNextmapRequest", getRootElement(), externalNextmapRequest) sendo que: me = getLocalPlayer() Será que alguem consegue decifrar este erro? *PS, a função que esta ai declarada na race era de um outro script... que por sinal funcionava muito bem.
Anderl Posted July 2, 2012 Posted July 2, 2012 (edited) Server-side: addEvent( 'onExternalNextMapRequest', true ); addEventHandler( 'onExternalNextMapRequest', root, function( player, map ) local mapa, error = findMap( map ); if( not mapa ) then outputRace( error, player ); return; end g_ForcedNextMap = mapa; triggerClientEvent( 'setNextMap', root, getMapName( mapa ) ); triggerEvent( 'onBuyMapSetStatus', root, 'true' ); triggerEvent( 'onScriptSetNextMap', player, mapa ); end ) Client-side: function buyMap( ) if( getElementData( localPlayer, 'money' ) >= 5000 ) then -- Eu nao recomendo voce a usar element data com esse tipo de coisas triggerServerEvent( 'onExternalNextMapRequest', root, localPlayer, tostring( guiGetText( gui.mname ) or '' ) ); else outputChatBox( '[sHOP] #ffffffYou don\' have enough money to buy a map! 5000$ needed.', 255, 150, 150, true ); end end Eu não recomendo a você usar element data em jogadores pois element data é deletado quando o elemento é destruído. Bote isso no Race e tente, eu não testei... Edited July 3, 2012 by Guest
surfer Posted July 2, 2012 Author Posted July 2, 2012 Então, dei uma experimentada aqui o painel acabou por nem responder... não acusa erro, mas tbm não abre ai agr que me dei conta aqui, postei 3 trechos de scrpit, e acho que não expliquei muito bem ^^ O 1° trecho, vai no script server O 2° vai no script cliente Sendo os dois no "user-panel" e o 3° trecho que é a parte que "me falta" vai na race implantado dentro do "racevoting_server.lua" que é que vai efetivamente setar o mapa quando um player o compra. vou dar mais um trabalhada aqui, tenho um outro user panel que funciona perfeitamente, que foi de onde eu tirei a função que postei aqui...
surfer Posted July 3, 2012 Author Posted July 3, 2012 dei uma mexida aqui agr o console me voltou este erro [2012-07-02 21:24:51] ERROR: [gamemodes]\[race]\[addons]\Pinkpanel\s.lua:178: attempt to call global 'findMap' (a nil value) já é um progresso... Antes não estava abrindo por que haiva um outputchatbox com ' e isso confundiu um pouco, depois que peguei com bastante calma ele rodou.
Anderl Posted July 3, 2012 Posted July 3, 2012 Copie meu último código e bote isso no "racevoting_server.lua": function findMap( mapName ) if( mapName and type( mapName ) == 'string' and mapName ~= '' ) then local t = exports.mapmanager:getMapsCompatibleWithGamemode( getResourceFromName( 'race' ) ); for i,v in ipairs( t ) do if( tostring( getResourceInfo( v, 'name' ) ) == tostring( mapName ) ) then return v; end end end return 'Unable to find choosed map!'; end
Recommended Posts