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

Action Lotery ticket Script!

Exedion

Active Member
Joined
Jun 11, 2007
Messages
628
Reaction score
30
Well other of my easy scripts but full usefull for rpg's servers! jejej, here we go:

Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local value = math.random(5956, 5958)
	doTransformItem(item.uid, value)
	return TRUE
end

and add this to you action.xml

Code:
<action itemid="5957" script="lotery.lua"/>

lotery ticket closed: 5957
lotery ticket looser: 5956
lotery ticket winner: 5958

have fun with your addon system xD ^^
 
Hmm, what does the player win? I can't see anything about a itemID that the player gets when he wins, and I can't even see anything about some text that the player gets when he\she looses\wins. Do you mind explaining?
 
Mate u forgot to add somting how does the player know that hewon? if it dosen't have an description!
 
ya, he did, didn't he? I really thought so too... :p


Hmm try somting like this

=====Not tested=========


Code:
function onUse(cid, item, frompos, item2, topos)
rand = math.random(1, 10)

     if rand > 2 then
	 if doPlayerTakeItem(cid,5957,1) then
	 local ticket = doPlayerAddItem(cid,5957,1)
doSetItemSpecialDescription(ticket,'It is an losing ticket!')
	
	 elseif rand == 1 then
	 if doPlayerTakeItem(cid,5957,1) then
	 local ticket = doPlayerAddItem(cid,5957,1)
doSetItemSpecialDescription(ticket,'Congratulations, You have an Winning Ticket!')
	else
			doPlayerSendCancel(cid, "Sorry, not possible.")
	end
	end
	end
	return true
end
 
@Mokerhamer
Your script is wrong, look at this:

Code:
local ticket = doPlayerAddItem(cid,5957,1)
doSetItemSpecialDescription(ticket,'Congratulations, You have an Winning Ticket!')

You are setting the var ticket a special description, you have to set in the id and not in a function that uses the id...
 
@Mokerhamer
Your script is wrong, look at this:

Code:
local ticket = doPlayerAddItem(cid,5957,1)
doSetItemSpecialDescription(ticket,'Congratulations, You have an Winning Ticket!')

You are setting the var ticket a special description, you have to set in the id and not in a function that uses the id...

I know what u mean but, you need to do it like that because if it dont removeds the ticket/adds it again you cant set an discription because the uid wont acsept it
 
Hmm try somting like this

=====Not tested=========


Code:
function onUse(cid, item, frompos, item2, topos)
rand = math.random(1, 10)

     if rand > 2 then
	 if doPlayerTakeItem(cid,5957,1) then
	 local ticket = doPlayerAddItem(cid,5957,1)
doSetItemSpecialDescription(ticket,'It is an losing ticket!')
	
	 elseif rand == 1 then
	 if doPlayerTakeItem(cid,5957,1) then
	 local ticket = doPlayerAddItem(cid,5957,1)
doSetItemSpecialDescription(ticket,'Congratulations, You have an Winning Ticket!')
	else
			doPlayerSendCancel(cid, "Sorry, not possible.")
	end
	end
	end
	return true
end

Code:
function onUse(cid, item, frompos, item2, topos)
	local rand = math.random(1, 10)
	if rand ~= 1 then
		doSetItemSpecialDescription(item.uid,'It is an losing ticket!')
	else
		doSetItemSpecialDescription(item.uid,'Congratulations, You have an Winning Ticket!')
	end
	return 1
end

It's useless to remove an item and add a different one with exact same itemid just because you want to get the item uid. You can just use item.uid in the first place and avoid all that trouble.
I didn't understand why you have the else 'Sorry not possible' since it's not gonna be anything else.

Anyways, the first post in this thread didn't seem bad. Item description can be set in items.xml... If player gets a winning lottery, he can trade it for the addon.
 
Last edited:
Code:
function onUse(cid, item, frompos, item2, topos)
	local rand = math.random(1, 10)
	if rand ~= 1 then
		doSetItemSpecialDescription(ticket,'It is an losing ticket!')
	else
		doSetItemSpecialDescription(ticket,'Congratulations, You have an Winning Ticket!')
	end
	return 1
end

It's useless to remove an item and add a different one with exact same itemid just because you want to get the item uid. You can just use item.uid in the first place and avoid all that trouble.
I didn't understand why you have the else 'Sorry not possible' since it's not gonna be anything else.

Anyways, the first post in this thread didn't seem bad. Item description can be set in items.xml... If player gets a winning lottery, he can trade it for the addon.

that's true but how can the npc see if it's and winning ticket! the npc can see it trough the item.uid id! or the npc's cant check if it's an winning ticket
 
that's true but how can the npc see if it's and winning ticket! the npc can see it trough the item.uid id! or the npc's cant check if it's an winning ticket

On first post, the guy says
lotery ticket closed: 5957
lotery ticket looser: 5956
lotery ticket winner: 5958

So... if player has the item 5958 then give the player the addon.
Meaing: the script in first post is fine, he just didn't make the NPC that takes the lottery ticket and gives u addon for it.
 
On first post, the guy says


So... if player has the item 5958 then give the player the addon.
Meaing: the script in first post is fine, he just didn't make the NPC that takes the lottery ticket and gives u addon for it.

That's true but the last 2 ids look the same! how can the player check if the are winning tickets or not? only throug npc wouldent it be bether if it has an discription so he can sell/trade it to other players, now players can fake lottery ticket by saing it's an winning but it's not true!
 
That's true but the last 2 ids look the same! how can the player check if the are winning tickets or not? only throug npc wouldent it be bether if it has an discription so he can sell/trade it to other players, now players can fake lottery ticket by saing it's an winning but it's not true!

Add description using items.xml to the item itself.
 
yes inspiro have the reason! i dont put the part of items.xml, because all can do these -.-

In my opinion, I think you should've atleast mentioned it that we should put the description on items.xml outselves. Just because most of us know how to put description on items.xml, doesn't mean you shouldn't tell us that we should. Anyways, the script has a small error. When you use the lottery ticket, there's a chance it'll just turn into the same item we just used.
 
In my opinion, I think you should've atleast mentioned it that we should put the description on items.xml outselves. Just because most of us know how to put description on items.xml, doesn't mean you shouldn't tell us that we should. Anyways, the script has a small error. When you use the lottery ticket, there's a chance it'll just turn into the same item we just used.

That's true in my opinion you can use them both, with one it will set discription at the other u need to set it yur self it de
 
Hmm try somting like this

=====Not tested=========


Code:
function onUse(cid, item, frompos, item2, topos)
rand = math.random(1, 10)

     if rand > 2 then
	 if doPlayerTakeItem(cid,5957,1) then
	 local ticket = doPlayerAddItem(cid,5957,1)
doSetItemSpecialDescription(ticket,'It is an losing ticket!')
	
	 elseif rand == 1 then
	 if doPlayerTakeItem(cid,5957,1) then
	 local ticket = doPlayerAddItem(cid,5957,1)
doSetItemSpecialDescription(ticket,'Congratulations, You have an Winning Ticket!')
	else
			doPlayerSendCancel(cid, "Sorry, not possible.")
	end
	end
	end
	return true
end
i think i see a typo, shouldn't it be "You have a Winning ticket, and a losing ticket?
 
@up: It seems perfectly fine in my view. There's a 10% chance that you win, and you know by looking at the ticket you'll see "Congratulations, You have a winning ticket". If you lost, you'll see "It is an losing ticket". The script itself could've been done better as I already mentioned, but it's perfectly functional ingame.
 
Back
Top