Narutimmy Posted February 17, 2013 Share Posted February 17, 2013 Hola miren tengo este scrip de la comunidad que hace que cuando mueras tu dinero se queda tirado en el piso. function createMoney(player) local x, y, z = getElementPosition(player); local x1, y1, x2, y2; x1 = (x-2)+(math.random()*4); y1 = (y-2)+(math.random()*4); x2 = (x-2)+(math.random()*4); y2 = (y-2)+(math.random()*4); local moneyAmmount = getPlayerMoney(player); -- it is not fair too get all the player money. moneyAmmount = math.floor(moneyAmmount/1); takePlayerMoney(player, moneyAmmount); -- We are going to create 3 pickups, zo we are just cut the ammount in half moneyAmmount = math.floor(moneyAmmount/3); -- Create the pickups setElementData(createPickup(x1, y1, z, 3, 1212), "ammount", moneyAmmount); setElementData(createPickup(x2, y2, z, 3, 1212), "ammount", moneyAmmount); setElementData(createPickup(x2, y2, z, 3, 1212), "ammount", moneyAmmount); end function moneyPickupHit(player) local money = getElementData(source, "ammount"); if money then givePlayerMoney(player, money); destroyElement(source); end end function playerJustGotDied(ammo, attacker, weapon, bodypart) createMoney(source); end addEventHandler("onPickupUse", getRootElement(), moneyPickupHit); addEventHandler("onPlayerWasted", getRootElement(), playerJustGotDied); Pero como puedo hacer para que si eres de nivel 10 o menor cuando te maten no pierdas el dinero? Link to comment
Alexs Posted February 17, 2013 Share Posted February 17, 2013 Con un estamento: if not level > 10 then o if level < 10 then y ahí acomodas tu el como consigues el nivel del jugador. Link to comment
Narutimmy Posted February 17, 2013 Author Share Posted February 17, 2013 Con un estamento: if not level > 10 then o if level < 10 then y ahí acomodas tu el como consigues el nivel del jugador. Justo algo asi me imagine pero no estaba seguro, gracias. Link to comment
Narutimmy Posted February 17, 2013 Author Share Posted February 17, 2013 Con un estamento: if not level > 10 then o if level < 10 then y ahí acomodas tu el como consigues el nivel del jugador. No estoy seguro pero es algo asi: ? function createMoney(player) local x, y, z = getElementPosition(player); local x1, y1, x2, y2; x1 = (x-2)+(math.random()*4); y1 = (y-2)+(math.random()*4); x2 = (x-2)+(math.random()*4); y2 = (y-2)+(math.random()*4); local moneyAmmount = getPlayerMoney(player); -- it is not fair too get all the player money. moneyAmmount = math.floor(moneyAmmount/1); takePlayerMoney(player, moneyAmmount); -- We are going to create 3 pickups, zo we are just cut the ammount in half moneyAmmount = math.floor(moneyAmmount/3); -- Create the pickups setElementData(createPickup(x1, y1, z, 3, 1212), "ammount", moneyAmmount); setElementData(createPickup(x2, y2, z, 3, 1212), "ammount", moneyAmmount); setElementData(createPickup(x2, y2, z, 3, 1212), "ammount", moneyAmmount); end function moneyPickupHit(player) local money = getElementData(source, "ammount"); if money then givePlayerMoney(player, money); destroyElement(source); end end function playerJustGotDied(ammo, attacker, weapon, bodypart) if not level > 10 then createMoney(source); end addEventHandler("onPickupUse", getRootElement(), moneyPickupHit); addEventHandler("onPlayerWasted", getRootElement(), playerJustGotDied); Link to comment
Castillo Posted February 17, 2013 Share Posted February 17, 2013 "level" no esta definido. Link to comment
Narutimmy Posted February 17, 2013 Author Share Posted February 17, 2013 "level" no esta definido. Asi ? local level = tonumber ( getElementData ( thePlayer, "level" ) ) or 0 function playerJustGotDied(ammo, attacker, weapon, bodypart) if not level > 10 then createMoney(source); end addEventHandler("onPickupUse", getRootElement(), moneyPickupHit); addEventHandler("onPlayerWasted", getRootElement(), playerJustGotDied); Link to comment
Castillo Posted February 17, 2013 Share Posted February 17, 2013 No, tiene que ir dentro de la funcion y usa "source" no "thePlayer". Link to comment
Narutimmy Posted February 17, 2013 Author Share Posted February 17, 2013 No, tiene que ir dentro de la funcion y usa "source" no "thePlayer". Intente asi: local level = tonumber ( getElementData ( source, "level" ) ) or 0 function playerJustGotDied(ammo, attacker, weapon, bodypart) if not level > 10 then createMoney(source); end addEventHandler("onPickupUse", getRootElement(), moneyPickupHit); addEventHandler("onPlayerWasted", getRootElement(), playerJustGotDied); Pero ahora al morir seas o no menos a nv 10 no pierdes el dinero... como debe ir asi? function playerJustGotDied(ammo, attacker, weapon, bodypart) local level = tonumber ( getElementData ( source, "level" ) ) or 0 if not level > 10 then createMoney(source); end addEventHandler("onPickupUse", getRootElement(), moneyPickupHit); addEventHandler("onPlayerWasted", getRootElement(), playerJustGotDied); Link to comment
Castillo Posted February 17, 2013 Share Posted February 17, 2013 Te falta un 'end' y ese 'if' esta mal hecho. function playerJustGotDied(ammo, attacker, weapon, bodypart) local level = tonumber ( getElementData ( source, "level" ) ) or 0 if ( level > 10 ) then createMoney ( source ) end end addEventHandler("onPickupUse", getRootElement(), moneyPickupHit); addEventHandler("onPlayerWasted", getRootElement(), playerJustGotDied); Link to comment
Narutimmy Posted February 17, 2013 Author Share Posted February 17, 2013 Te falta un 'end' y ese 'if' esta mal hecho. function playerJustGotDied(ammo, attacker, weapon, bodypart) local level = tonumber ( getElementData ( source, "level" ) ) or 0 if ( level > 10 ) then createMoney ( source ) end end addEventHandler("onPickupUse", getRootElement(), moneyPickupHit); addEventHandler("onPlayerWasted", getRootElement(), playerJustGotDied); muchas Gracias Link to comment
Narutimmy Posted February 17, 2013 Author Share Posted February 17, 2013 De nada. Una Pequeña Duda... como podria hacer que al morir de igual forma de nv10 o menos no pierdan las armas? esque eso es con otro scrip que lso manda a un hospital y se las quita, intente con function armas() local level = tonumber ( getElementData ( source, "level" ) ) or 0 if ( level < 10 ) then giveWeapon ( source, 22, 100 ) giveWeapon ( source, 28, 300 ) end end addEventHandler("onPlayerWasted", getRootElement(), armas); Para que reciba esas 2 armas pero no se las da Link to comment
Arsilex Posted February 17, 2013 Share Posted February 17, 2013 deberia de darselas.. algun error? tambien intenta poniendo un timer por si es por eso osea un timer que al morir al pasar 5 seg te de esas armas- Link to comment
Narutimmy Posted February 17, 2013 Author Share Posted February 17, 2013 deberia de darselas.. algun error?tambien intenta poniendo un timer por si es por eso osea un timer que al morir al pasar 5 seg te de esas armas- se usar un timer pero como lo usaria en este caso? solo se usarlo para que active una funcion cada sierto tiempo? Link to comment
Arsilex Posted February 17, 2013 Share Posted February 17, 2013 function armas() local level = tonumber ( getElementData ( source, "level" ) ) or 0 if ( level < 10 ) then setTimer ( function(source) giveWeapon ( source, 22, 100 ) giveWeapon ( source, 28, 300 ) end, 5000, 1 ) end end addEventHandler("onPlayerWasted", getRootElement(), armas); Link to comment
Recommended Posts