Crow Posted June 6, 2013 Share Posted June 6, 2013 Bueno la cosa es que tengo un resource para comprar skins. Todo bien puedo añadir el skin y cambiar el precio pero el problema esta en que el resource no trae un codigo que avise al jugador que no tiene dinero suficiente para comprar el skin. Esto hace que aunque no tengan el dinero igual pueden comprarlo y el dinero que tienen disminuye a menos y se pone rojo. Ejemplo el skin vale 10000 y si el usuario tiene 5000 lo puede comprar igual y la diferencia pasa a negativo Solo quiero saber ¿ qué script debo añadirle para que no puedan comprarlo si no tienen el dinero ? Saludos Link to comment
Bc# Posted June 6, 2013 Share Posted June 6, 2013 No tienes que agregar un script como lo llamas ni tampoco una función tienes que agregar una condición ejemplo: --Tomando en cuenta que tu variable de dinero es playercash y el skin el precio del skin es skinCost entonces if playerCash >= skincost then outputChatBox ( "Has comprado tu Skin Satisfactoriamente", getRootElement(), 255, 255, 255, true ) else outputChatBox ( "Tu dinero no es suficiente para comprar este skin", getRootElement(), 255, 0, 0, true ) end Toma en cuenta que mis variables son solo hipotéticas tu tienes que usar las de tu script. Link to comment
Crow Posted June 6, 2013 Author Share Posted June 6, 2013 Wow gracias pero no sabria donde ubicarlo y si funcionaria con el script que tengo .. aun asi te dejo el script de lso dos archivos que requiere marker = createMarker( 2247.3356933594, -1664.8883056641, 14.4765625, "cylinder", 2, 255, 255, 0, 255 ) blip = createBlip( 2247.3356933594, -1664.8883056641, 14.4765625, 45 ) function buy(id) reskin = setElementModel(source, id) takePlayerMoney(source, 50000) playeraccount = getPlayerAccount(source) setAccountData(playeraccount, "standardskin", id) end addEvent("useSkin",true) addEventHandler("useSkin", root, buy) function guishow(hitPlayer) triggerClientEvent (hitPlayer,"guishowc",getRootElement(),hitPlayer) end addEventHandler("onMarkerHit",marker,guishow) Wnd = guiCreateWindow ( 0.2, 0.2, 0.25, 0.5, "Skin shop", true ) guiSetAlpha( Wnd, 1 ) button = guiCreateButton ( 0.01, 0.8, 0.99, 0.15, "Close", true, Wnd ) label = guiCreateLabel ( 0.1, 0.1, 0.9, 0.1, "Double click on skin. ($50000)", true, Wnd ) showCursor(false) guiSetVisible( Wnd, false ) guiWindowSetSizable( Wnd, false ) guiWindowSetMovable( Wnd, false ) vehicles = { {"nombredelskin", id}, {"nombredelskin", id}, {"nombredelskin", id}, } grid = guiCreateGridList(0.01, 0.2, 0.99, 0.5, true, Wnd) guiGridListAddColumn(grid, "Skins", 0.85) for i,veh in ipairs(vehicles) do row = guiGridListAddRow(grid) -- guiGridListSetItemText(grid, row, 1, tostring(veh[1]), false, false) guiGridListSetItemData(grid, row, 1, tostring(veh[2])) end function use() local row, col = guiGridListGetSelectedItem(grid) if (row and col and row ~= -1 and col ~= -1) then local model = tonumber(guiGridListGetItemData(grid, row, 1)) if model ~= "" then triggerServerEvent("useSkin", localPlayer, model) end end end addEventHandler("onClientDoubleClick", root, use, false) function close() if (source == button) then guiSetVisible(Wnd,false) showCursor(false) end end addEventHandler("onClientGUIClick", button, close) function guishowc() guiSetVisible(Wnd,true) showCursor(true) end addEvent("guishowc",true) addEventHandler("guishowc", getRootElement(), guishowc) Link to comment
Sensacion Posted June 6, 2013 Share Posted June 6, 2013 precioSkin = 5000 function buy( id ) if ( getPlayerMoney( source ) >= precioSkin ) then setElementModel( source, id ) takePlayerMoney( source, precioSkin ) outputChatBox ( "Has comprado tu Skin Satisfactoriamente", source, 0, 255, 0, true ) else outputChatBox ( "Tu dinero no es suficiente para comprar este skin", source, 255, 0, 0, true ) end end addEvent( "useSkin", true ) addEventHandler( "useSkin", root, buy ) Link to comment
Crow Posted June 6, 2013 Author Share Posted June 6, 2013 Funciono !! Muchisimas Gracias !! a los dos por la ayuda ahora no tengo problemas con el resource GRACIAS ! Link to comment
Bc# Posted June 6, 2013 Share Posted June 6, 2013 Fue un placer ayudarte, ojala toda la gente que viene a pedir ayuda lo haga así mismo. Link to comment
Recommended Posts