Action Lotery ticket Script!

Exedion

Active Member
Joined
Jun 11, 2007
Messages
628
Best answers
0
Reaction score
28
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 ^^
 

JayBeee

Retired Global Mod
Joined
Jun 2, 2007
Messages
5,225
Best answers
0
Reaction score
13
Location
Sweden
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?
 

Mokerhamer

Retired Global Mod
Joined
Aug 6, 2007
Messages
1,766
Best answers
0
Reaction score
35
Mate u forgot to add somting how does the player know that hewon? if it dosen't have an description!
 

JayBeee

Retired Global Mod
Joined
Jun 2, 2007
Messages
5,225
Best answers
0
Reaction score
13
Location
Sweden
ya, he did, didn't he? I really thought so too... :p
 

Mokerhamer

Retired Global Mod
Joined
Aug 6, 2007
Messages
1,766
Best answers
0
Reaction score
35
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
 

Nostradamus

New Member
Joined
Jun 2, 2007
Messages
219
Best answers
0
Reaction score
4
@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

Retired Global Mod
Joined
Aug 6, 2007
Messages
1,766
Best answers
0
Reaction score
35
@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
 

Ispiro

New Member
Joined
Oct 1, 2007
Messages
129
Best answers
0
Reaction score
2
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:

Mokerhamer

Retired Global Mod
Joined
Aug 6, 2007
Messages
1,766
Best answers
0
Reaction score
35
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
 

Ispiro

New Member
Joined
Oct 1, 2007
Messages
129
Best answers
0
Reaction score
2
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.
 

gunmetal

New Member
Joined
Oct 15, 2007
Messages
75
Best answers
0
Reaction score
0
Seems good i might use this in my server but dont get it what does it do
 

Mokerhamer

Retired Global Mod
Joined
Aug 6, 2007
Messages
1,766
Best answers
0
Reaction score
35
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!
 

Ispiro

New Member
Joined
Oct 1, 2007
Messages
129
Best answers
0
Reaction score
2
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.
 
OP
Exedion

Exedion

Active Member
Joined
Jun 11, 2007
Messages
628
Best answers
0
Reaction score
28
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 -.-
 

Ispiro

New Member
Joined
Oct 1, 2007
Messages
129
Best answers
0
Reaction score
2
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.
 

Mokerhamer

Retired Global Mod
Joined
Aug 6, 2007
Messages
1,766
Best answers
0
Reaction score
35
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
 

Karel

Member
Joined
Sep 30, 2007
Messages
200
Best answers
0
Reaction score
5
Location
Holland
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?
 

Ispiro

New Member
Joined
Oct 1, 2007
Messages
129
Best answers
0
Reaction score
2
@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.
 
Top