• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua Simple but urgent requests, help needed. (STILL NOT SOLVED.. come on pr0s)

Guitar Freak

_LüA_n☺b_
Joined
Dec 27, 2008
Messages
831
Reaction score
13
Location
Caracas, Venezuela
Well as the title says Im having some requests that are probably very simple to some of you guys but I just cant finish getting them correctly and it pisses me off cause Im losing so much time, so its time to ask for a bit of help here.

  • Probably the most simple one, I need a talkaction called "!checkbless" that costs money to cast and it will show a message (preferably non-popup but not neccesary, Ill change that) saying:
    "You have successfully paid " .. amountofmoney .. " for your blessings check. Right now you have: first bless, second bless" etc. Or "You dont have any blessings." if none. [This one is solved]

  • Second one, I have a talkaction called !buyhp (and !buymana) that works fine, with it you can buy amounts of HP or Mana for a price permanently, but the problem is that I also want to have an NPC that does the same thing, sell HP/Mana but I cant make it work properly and I dont even know what Im doing there.

    Here is the script for the !buyhp talkaction, which is mixed to the !buymana one, it is 1 script for both (credits are not entirely mine, but you can use it for your server if you desire):

    buyhpmana.lua:
    PHP:
    local config = {
    	healthCost = 20000,
    	healthAmount = 100,
    	manaCost = 20000,
    	manaAmount = 100
    }
    
    function onSay(cid, words, param)
    	local fSet, fGet, fAdd = setCreatureMaxHealth, getCreatureMaxHealth, doCreatureAddHealth
    	local cost, amount = config.healthCost, config.healthAmount
    	local str = "health"
    
    	if(words == "!buymana") then
    		fSet, fGet, fAdd = setCreatureMaxMana, getCreatureMaxMana, doCreatureAddMana
    		cost, amount = config.manaCost, config.healthAmount
    		str = "mana"
    	end
    
    	if(doPlayerRemoveMoney(cid, cost) ~= TRUE) then
    		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Sorry, you dont have enough money. It costs 20k each 100 HP or Mana.")
    		return TRUE
    	end
    
    	fSet(cid, fGet(cid) + amount)
    	fAdd(cid, amount)
    	doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have bought " .. amount .. " " .. str .. " points.")
    	return TRUE
    end

    Anyone knows how to transpose that to an NPC?

  • Third and I think this one is a bit more complicated, something about money currencies.

    Right now I have 2 custom currencies going on in my server, they all work perfectly, you can correctly convert 100 cc to 1 of the 1st currency (lets call it X) and 100 X to 1 of 2nd currency (call it Y), you can buy stuff with any currency correctly, so NPCs recognize them as money and also talkactions do.

    The value table would be:
    100 gold > 1 platinum
    100 platinum > 1 crystal
    100 crystal > 1 X
    100 X > 1 Y

    The problem comes when you buy something cheap with lets say 1 Y, the NPCs dont recognize the custom currencies as "change", so if I buy something worth 10k with a coin thats worth 100 million, the change the NPC gives me back is all in CRYSTAL COINS (and plats, gold), so I get like 1000 packs of CCs in the bp + floor therefore I debug.

    I cant get my head around of why this happens, because if the NPCs recognize the currencies as money to buy stuff, why wont they give me the change in those currencies? Same with talkactions.

    This 3rd one is the most urgent one, but I think it is more complicated too. But I dont know, it might be something stupid Im missing.

    I dont think this is a problem of the scripts, but if you need all the scripts that relate to my currencies I can post them, just tell me.

Any suggestions appreciated, Ill tell you if Ive done them already or not.

Needless to say, I will +REP everyone who HELPS me on any of the issues.
Not random posters, but the helpful ones.

Thanks in advance.
Cheers.
 
Last edited:
Hi, im not an scripter.. i just "know something" but for the bless issue i think there should be an action called getPlayerBlessing or getPlayerBless im almost sure of have seen it. about the other issues you have i have no clue xD its kinda hard. Good luck anyway :)

edit:
Also agreed with Grehy post.
 
Last edited:
!checkbless
LUA:
function onSay(cid, words, param)
local amountofmoney = 1000
      
      if getPlayerMoney(cid) >= amountofmoney then
         if getPlayerBlessing(cid, 1) == 1 then
            doPlayerSendTextMessage(cid, 27, "You have successfully paid " .. amountofmoney .. " for your blessings check. Right now you have: first bless.")
            doPlayerRemoveMoney(cid, amountofmoney)
            
         elseif getPlayerBlessing(cid, 1) == 1 and getPlayerBlessing(cid, 2) == 1 then
            doPlayerSendTextMessage(cid, 27, "You have successfully paid " .. amountofmoney .. "GPS for your blessings check. Right now you have: first bless and second bless.")
            doPlayerRemoveMoney(cid, amountofmoney)
                        
         elseif getPlayerBlessing(cid, 1) == 1 and getPlayerBlessing(cid, 2) == 1 and getPlayerBlessing(cid, 3) == 1 then
            doPlayerSendTextMessage(cid, 27, "You have successfully paid " .. amountofmoney .. "GPS for your blessings check. Right now you have: first bless, second bless and third bless.")
            doPlayerRemoveMoney(cid, amountofmoney)
                        
         elseif getPlayerBlessing(cid, 1) == 1 and getPlayerBlessing(cid, 2) == 1 and getPlayerBlessing(cid, 3) == 1 and getPlayerBlessing(cid, 4) == 1 then
            doPlayerSendTextMessage(cid, 27, "You have successfully paid " .. amountofmoney .. "GPS for your blessings check. Right now you have: first bless, second bless, third bless and fourth bless.")
            doPlayerRemoveMoney(cid, amountofmoney)
                        
         elseif getPlayerBlessing(cid, 1) == 1 and getPlayerBlessing(cid, 2) == 1 and getPlayerBlessing(cid, 3) == 1 and getPlayerBlessing(cid, 4) == 1 and getPlayerBlessing(cid, 5) == 1 then
            doPlayerSendTextMessage(cid, 27, "You have successfully paid " .. amountofmoney .. "GPS for your blessings check. Right now you have: first bless, second bless, third bless, fourth bless and fifth bless.")
            doPlayerRemoveMoney(cid, amountofmoney)
            
         else
            doPlayerSendTextMessage(cid, 27, "You have successfully paid " .. amountofmoney .. "GPS for your blessings check. Right now you do not have any blessings.")
            doPlayerRemoveMoney(cid, amountofmoney)               
         end
      else
          doPlayerSendCancel(cid, "You do not have enough money")
      end
         return TRUE
end
 
Last edited:
!checkbless
LUA:
function onSay(cid, words, param)
local amountofmoney = 1000
      
      if getPlayerMoney(cid) >= amountofmoney then
         if getPlayerBlessing(cid, 1) == 1 then
            doPlayerSendTextMessage(cid, 27, "You have successfully paid " .. amountofmoney .. " for your blessings check. Right now you have: first bless.")
            doPlayerRemoveMoney(cid, amountofmoney)
            
         elseif getPlayerBlessing(cid, 1) == 1 and getPlayerBlessing(cid, 2) == 1 then
            doPlayerSendTextMessage(cid, 27, "You have successfully paid " .. amountofmoney .. "GPS for your blessings check. Right now you have: first bless and second bless.")
            doPlayerRemoveMoney(cid, amountofmoney)
                        
         elseif getPlayerBlessing(cid, 1) == 1 and getPlayerBlessing(cid, 2) == 1 and getPlayerBlessing(cid, 3) == 1 then
            doPlayerSendTextMessage(cid, 27, "You have successfully paid " .. amountofmoney .. "GPS for your blessings check. Right now you have: first bless, second bless and third bless.")
            doPlayerRemoveMoney(cid, amountofmoney)
                        
         elseif getPlayerBlessing(cid, 1) == 1 and getPlayerBlessing(cid, 2) == 1 and getPlayerBlessing(cid, 3) == 1 and getPlayerBlessing(cid, 4) == 1 then
            doPlayerSendTextMessage(cid, 27, "You have successfully paid " .. amountofmoney .. "GPS for your blessings check. Right now you have: first bless, second bless, third bless and fourth bless.")
            doPlayerRemoveMoney(cid, amountofmoney)
                        
         elseif getPlayerBlessing(cid, 1) == 1 and getPlayerBlessing(cid, 2) == 1 and getPlayerBlessing(cid, 3) == 1 and getPlayerBlessing(cid, 4) == 1 and getPlayerBlessing(cid, 5) == 1 then
            doPlayerSendTextMessage(cid, 27, "You have successfully paid " .. amountofmoney .. "GPS for your blessings check. Right now you have: first bless, second bless, third bless, fourth bless and fifth bless.")
            doPlayerRemoveMoney(cid, amountofmoney)
            
         else
            doPlayerSendTextMessage(cid, 27, "You have successfully paid " .. amountofmoney .. "GPS for your blessings check. Right now you do not have any blessings.")
            doPlayerRemoveMoney(cid, amountofmoney)               
         end
      else
          doPlayerSendCancel(cid, "You do not have enough money")
      end
         return TRUE
end

Didnt work but it gave me the idea of how its done and after messing around with it a bit I think I know how to make it work so ty :thumbup: +Rep

Ill post the working script when I have the time to do it.

· First request [Solved]

Anyone knows about the other 2 requests?

http://otland.net/f16/simple-but-urgent-requests-help-needed-rep-31657/#post319604
 
-Bumpek-

If you're too lazy to check first post, these are the ones Im still left to accomplish:

  • I have a talkaction called !buyhp (and !buymana) that works fine, with it you can buy amounts of HP or Mana for a price permanently, but the problem is that I also want to have an NPC that does the same thing, sell HP/Mana but I cant make it work properly and I dont even know what Im doing there.

    Here is the script for the !buyhp talkaction, which is mixed to the !buymana one, it is 1 script for both (credits are not entirely mine, but you can use it for your server if you desire):

    buyhpmana.lua:
    PHP:
    local config = {
    	healthCost = 20000,
    	healthAmount = 100,
    	manaCost = 20000,
    	manaAmount = 100
    }
    
    function onSay(cid, words, param)
    	local fSet, fGet, fAdd = setCreatureMaxHealth, getCreatureMaxHealth, doCreatureAddHealth
    	local cost, amount = config.healthCost, config.healthAmount
    	local str = "health"
    
    	if(words == "!buymana") then
    		fSet, fGet, fAdd = setCreatureMaxMana, getCreatureMaxMana, doCreatureAddMana
    		cost, amount = config.manaCost, config.healthAmount
    		str = "mana"
    	end
    
    	if(doPlayerRemoveMoney(cid, cost) ~= TRUE) then
    		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Sorry, you dont have enough money. It costs 20k each 100 HP or Mana.")
    		return TRUE
    	end
    
    	fSet(cid, fGet(cid) + amount)
    	fAdd(cid, amount)
    	doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have bought " .. amount .. " " .. str .. " points.")
    	return TRUE
    end

    Anyone knows how to transpose that to an NPC?

  • Third and I think this one is a bit more complicated, something about money currencies.

    Right now I have 2 custom currencies going on in my server, they all work perfectly, you can correctly convert 100 cc to 1 of the 1st currency (lets call it X) and 100 X to 1 of 2nd currency (call it Y), you can buy stuff with any currency correctly, so NPCs recognize them as money and also talkactions do.

    The value table would be:
    100 gold > 1 platinum
    100 platinum > 1 crystal
    100 crystal > 1 X
    100 X > 1 Y

    The problem comes when you buy something cheap with lets say 1 Y, the NPCs dont recognize the custom currencies as "change", so if I buy something worth 10k with a coin thats worth 100 million, the change the NPC gives me back is all in CRYSTAL COINS (and plats, gold), so I get like 1000 packs of CCs in the bp + floor therefore I debug.

    I cant get my head around of why this happens, because if the NPCs recognize the currencies as money to buy stuff, why wont they give me the change in those currencies? Same with talkactions.

    This last one is the most urgent one, but I think it is more complicated too. But I dont know, it might be something stupid Im missing.

    I dont think this is a problem of the scripts considering the NPCs/Talkactions do recognize them, but if you need all the scripts that relate to my currencies I can post them, just tell me.

Any suggestions appreciated, even if you can at least point me out on the right direction (including source editing related, like which files to look).

Come on pr0s.. someone must know about this.

Again, I will +REP everyone who helps me on any of the issues.

Thanks again.
Cheers.
 
Back
Top