• 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!

Quick script revision;

Evan

A splendid one to behold
Senator
Premium User
Joined
May 6, 2009
Messages
7,018
Solutions
1
Reaction score
1,040
Location
United States
Greetings,

I am hoping someone could give me a quick revision in this script.
Currently, I have it set so it checks if you have more than 50,000 gold and has a success in the random, it would summon a boss.
But if either one fails, it sends this message "You either don't have enough money or Robin Hood did not come visit at this time!".

What I'm hoping someone could do is separate them, for example, if you don't have enough gold, it would say
"You do not have enough gold" and if your luck doesn't succeed, it would say "Robin Hood did not come visit this time".


Hope someone understands.

Here is the WORKING script for both at the same time:

LUA:
function onUse(cid, item, fromPosition, itemEx, toPosition)
monster_pos = {x=842, y=1048, z=10}  
money = getPlayerMoney(cid)
success = math.random(1, 7)
  
        if item.itemid == 1945 and money >= 50000 and success == 1 then 
            	doPlayerRemoveMoney(cid, 50000) 
                doTransformItem(item.uid, 1946)  
            	addEvent(summonMonster, 3 * 1000)
			doBroadcastMessage("Robin Hood, the prince of thieves has come to the town to steal gold.  End him! End him for once and for all!", 22) 
        elseif item.itemid == 1946 then
            doTransformItem(item.uid, 1945)  
        else
            doCreatureSay(cid, "You either don't have enough money or Robin Hood did not come visit at this time!", TALKTYPE_ORANGE_1)
            doPlayerRemoveMoney(cid, 50000) 
        end  
    return TRUE 
end  
  
function summonMonster()   
    		doSummonCreature('Robin Hood', monster_pos)
		doSendMagicEffect(monster_pos, 10)  
end


REP++ to the one who has the working script
thanks,
Lostboy
 
LUA:
function onUse(cid, item, fromPosition, itemEx, toPosition)
monster_pos = {x=842, y=1048, z=10}  
money = getPlayerMoney(cid)
success = math.random(1, 7)
 
        if item.itemid == 1945 and money >= 50000 then
                if success == 1 then
            	doPlayerRemoveMoney(cid, 50000) 
                doTransformItem(item.uid, 1946)  
            	addEvent(summonMonster, 3 * 1000)
			doBroadcastMessage("Robin Hood, the prince of thieves has come to the town to steal gold.  End him! End him for once and for all!", 22)
               else
                      doCreatureSay(cid, "You don't have enough money !", TALKTYPE_ORANGE_1)
                end 
          else
                      doCreatureSay(cid, "Robin Hood did not come visit at this time!", TALKTYPE_ORANGE_1)
               end
         elseif item.itemid == 1946 then
            doTransformItem(item.uid, 1945) 
       end
    return TRUE 
end  
 
function summonMonster()   
    		doSummonCreature('Robin Hood', monster_pos)
		doSendMagicEffect(monster_pos, 10)  
end
 
Last edited:
Okay, problem.

When I pull lever, it says "You don't have enough money !" when I have 100 crystal coins in my backpack, also it does take gold away.
Then after some time clicking the lever, it summoned the boss and says "Robin Hood did not come visit at this time" (assuming the random was a success).
But after that, the switch won't go back the other way and continues to say "Robin Hood did not come visit at this time" forever and does not take any money away.

There seems to be no errors in the EXE.

I haven't really LOOKED into the script to see if I can easily fix it around due to the amount of time.
So, if you would double check the story and the script, would be helpful.

I gotta go to school now,
Thanks Elaney
 
Here, just fixed the messed up stuff
LUA:
function onUse(cid, item, fromPosition, itemEx, toPosition)
monster_pos = {x=842, y=1048, z=10}  
money = getPlayerMoney(cid)
success = math.random(1, 7)
 
        if item.itemid == 1945 and money >= 50000 then
           if success == 1 then
          	  doPlayerRemoveMoney(cid, 50000) 
              doTransformItem(item.uid, 1946)  
          	  addEvent(summonMonster, 3 * 1000)
              doBroadcastMessage("Robin Hood, the prince of thieves has come to the town to steal gold.  End him! End him for once and for all!", 22)
           else
               doCreatureSay(cid, "Robin Hood did not come visit at this time!", TALKTYPE_ORANGE_1)
           end
        elseif money < 50000 then
               doCreatureSay(cid, "You don't have enough money !", TALKTYPE_ORANGE_1)
        elseif item.itemid == 1946 then
               doTransformItem(item.uid, 1945) 
        end
 return true
end  
 
function summonMonster()   
         doSummonCreature('Robin Hood', monster_pos)
		 doSendMagicEffect(monster_pos, 10)  
end
 
even more cleaned:
LUA:
function onUse(cid, item, fromPosition, itemEx, toPosition)
monster_pos = {x=842, y=1048, z=10}  
success = math.random(1, 7)
	if item.itemid == 1945 and success == 1 then 
		if doPlayerRemoveMoney(cid, 50000) then
			doTransformItem(item.uid, 1946)  
			addEvent(summonMonster, 3 * 1000)
			doBroadcastMessage("Robin Hood, the prince of thieves has come to the town to steal gold.  End him! End him for once and for all!", 22)
		else
			doCreatureSay(cid, "You don't have enough money !", TALKTYPE_ORANGE_1)
		end
	elseif item.itemid == 1946 then
		doTransformItem(item.uid, 1945) 
	else
		doCreatureSay(cid, "Robin Hood did not come visit at this time!", TALKTYPE_ORANGE_1)
	end
	return true
end  
 
function summonMonster()   
	doSummonCreature('Robin Hood', monster_pos)
	doSendMagicEffect(monster_pos, 10)  
end



kind regards, Evil Hero.
 
Last edited:
Evil Hero's script worked, haven't tested the others, but thanks everyone!
I will rep++ all of you :)
 
It might be just me but i dont see the point of declaring global variables if they're only used once.
LUA:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if item.itemid == 1945 then
		if math.random(7) ~= 1 then
			return doCreatureSay(cid, 'Robin Hood did not come visit at this time!', TALKTYPE_ORANGE_1)
		elseif not doPlayerRemoveMoney(cid, 50000) then
			return doCreatureSay(cid, 'You don\'t have enough money!', TALKTYPE_ORANGE_1)
		else
			addEvent(doCreateMonster, 3000, 'Robin Hood', {x=842, y=1048, z=10})
			doBroadcastMessage('Robin Hood, the prince of thieves has come to the town to steal gold. End him! End him for once and for all!', MESSAGE_EVENT_ADVANCE)
		end
	end
	return doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
end
 
Back
Top