Jump to content

[Ayuda] Dinero al morir


Narutimmy

Recommended Posts

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
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
"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
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

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
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
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
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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...