Alexs Posted July 15, 2012 Posted July 15, 2012 Hola a Todos, este es el script de envio de dinero que yo uso: function giveSomeoneMoney(player, cmd, target, amount) if target then if amount then local money = getPlayerMoney(player) local targetplayer = getPlayerFromName(target) amount = tonumber(amount) if targetplayer then if money >= amount then givePlayerMoney(targetplayer, amount) takePlayerMoney(player, amount) outputChatBox(getPlayerName(player).." dio "..amount.." a "..getPlayerName(targetplayer), getRootElement(), 205, 092, 092, true) else outputChatBox("No tienes suficiente dinero!", player, 205, 092, 092) end else outputChatBox("Error: Player no encontrado", player, 205, 092, 092) end else outputChatBox("Error: /dardinero [Jugador] [Monto]", player, 205, 092, 092) end else outputChatBox("Error: /dardinero [Jugador] [Monto]", player, 205, 092, 092) end end addCommandHandler("dardinero", giveSomeoneMoney) Pero descubri un bug, al poner un numero negativo el script le roba a otro, te da a ti y le quita al otro, como puedo evitar que el argumento "amount" comienze con un signo negativo? Developer @ MYVAL
Castillo Posted July 15, 2012 Posted July 15, 2012 Verifica si "amount" es mayor que 0. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Alexs Posted July 15, 2012 Author Posted July 15, 2012 Lo puse asi: function giveSomeoneMoney(player, cmd, target, amount) if target then if amount then local money = getPlayerMoney(player) local targetplayer = getPlayerFromName(target) amount = tonumber(amount) if targetplayer then if amount > 0 then --agregue esto! if money >= amount then givePlayerMoney(targetplayer, amount) takePlayerMoney(player, amount) outputChatBox(getPlayerName(player).." dio "..amount.." a "..getPlayerName(targetplayer), getRootElement(), 205, 092, 092, true) else outputChatBox("No tienes suficiente dinero!", player, 205, 092, 092) end else outputChatBox("Error: Player no encontrado", player, 205, 092, 092) end else outputChatBox("Error: /dardinero [Jugador] [Monto]", player, 205, 092, 092) end else outputChatBox("Error: /dardinero [Jugador] [Monto]", player, 205, 092, 092) end end end addCommandHandler("dardinero", giveSomeoneMoney) Pero dice: Error: /dardinero [Jugador] [Monto] Developer @ MYVAL
Castillo Posted July 15, 2012 Posted July 15, 2012 function giveSomeoneMoney ( player, cmd, target, amount ) if ( target ) and ( amount ) then local money = getPlayerMoney ( player ) local targetplayer = getPlayerFromName ( target ) local amount = tonumber ( amount ) if ( targetplayer ) then if ( amount > 0 ) then --agregue esto! if ( money >= amount ) then givePlayerMoney ( targetplayer, amount ) takePlayerMoney ( player, amount ) outputChatBox ( getPlayerName ( player ) .." dio "..amount.." a ".. getPlayerName ( targetplayer ), getRootElement(), 205, 092, 092, true ) else outputChatBox ( "No tienes suficiente dinero!", player, 205, 092, 092 ) end else outputChatBox ( "Error: El monto debe ser mayor que 0!", player, 205, 092, 092 ) end else outputChatBox ( "Error: Player no encontrado", player, 205, 092, 092 ) end else outputChatBox ( "Error: /dardinero [Jugador] [Monto]", player, 205, 092, 092 ) end end addCommandHandler ( "dardinero", giveSomeoneMoney ) San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Castillo Posted July 15, 2012 Posted July 15, 2012 De nada. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Recommended Posts