What's new

Kasyno - TFS 0.3.6 PL

Status
Not open for further replies.

Mag Egzorcysta

Advanced User
Joined
Apr 17, 2010
Messages
248
Reaction score
39
Dla d?wigni z prawej strony nadajemy jej aid 6000, dla tej na dole 6001, tej z lewej 6002, a u g?ry 6003.
-- Skrypt --
Code:
function onUse(cid, item, frompos, itemEx, topos)
local pos = getCreaturePosition(cid)
local config = {
                [6000] = {pos_kaski={x=pos.x+1,y=pos.y,z=pos.z,stackpos=255}, pos_nagrody={x=pos.x+1,y=pos.y+1,z=pos.z}},
                [6001] = {pos_kaski={x=pos.x,y=pos.y+1,z=pos.z,stackpos=255}, pos_nagrody={x=pos.x+1,y=pos.y+1,z=pos.z}},
                [6002] = {pos_kaski={x=pos.x-1,y=pos.y,z=pos.z,stackpos=255}, pos_nagrody={x=pos.x-1,y=pos.y+1,z=pos.z}},
                [6003] = {pos_kaski={x=pos.x,y=pos.y-1,z=pos.z,stackpos=255}, pos_nagrody={x=pos.x+1,y=pos.y-1,z=pos.z}}
                }
local config_2 = {
                [1] = {ile_cc=5, szansa=20, wygrana=15},
                [2] = {ile_cc=10, szansa=15, wygrana=25},
                [3] = {ile_cc=25, szansa=10, wygrana=50},
                [4] = {ile_cc=50, szansa=5, wygrana=100}
                }
local dzwignia = config[item.actionid]
local position_kasy = getThingFromPos(dzwignia.pos_kaski)
local rand = math.random(1,100)
if dzwignia then
    if item.itemid == 1945 then
        if position_kasy.itemid == 2160 then
            for i=1, #config_2 do
            if position_kasy.type == config_2[i].ile_cc then
                if rand >= config_2[i].szansa then
                    doTransformItem(item.uid, item.itemid+1)
                    doRemoveItem(position_kasy.uid, config_2[i].ile_cc)
                    doSendMagicEffect(dzwignia.pos_kaski, 2)
                    doPlayerSendTextMessage(cid, 22, "Straciles "..config_2[i].ile_cc.." Crystal Coins :(.")
                    return true
                else
                    doTransformItem(item.uid, item.itemid+1)
                    doRemoveItem(position_kasy.uid, config_2[i].ile_cc)
                    doCreateItem(2160, config_2[i].wygrana, dzwignia.pos_nagrody)
                    doSendMagicEffect(dzwignia.pos_nagrody, 13)
                    doSendMagicEffect(position_kasy, 21)
                    doPlayerSendTextMessage(cid, 22, "Gratulacje Wygrales "..config_2[i].wygrana.." Crystal Coins :).")
                    return true
                end
            end
            end
        else
            doPlayerSendTextMessage(cid, 22, "Poloz kase.")
            return true
        end
    elseif item.itemid == 1946 then
        doTransformItem(item.uid, item.itemid-1)
    end
end    
return true
end
W actions.xml doklejamy:
Code:
<action fromaid="6000" toaid="6003" event="script" value="kasyno1.lua"/>

//uaktualni?em Twoj? wersj?.
 

MaaX

Advanced User
Joined
Apr 12, 2008
Messages
231
Reaction score
11
Odp: Kasyno - TFS 0.3.6 PL

hmm ja mam maly problem bo jest podane id jakie ma miec dzwignia a miejsce gdzie trzeba polozyc kase jakie musi miec id ??
 

Mag Egzorcysta

Advanced User
Joined
Apr 17, 2010
Messages
248
Reaction score
39
Odp: Kasyno - TFS 0.3.6 PL

if(item.uid == 5885)then
kasapos = {x=506, y=211, z=6, stackpos=255}
winpos = {x=504, y=211, z=6}

Czerwony - UniqueID D?wigni,
Zielony - Miejsce gdzie gracz k?adzie kase,
Niebieski - Miejsce gdzie pojawia si? wygrana.


W miejsce kasy nie dajesz ?adnego ActionID lub UniqueID.
 

Drakee

Advanced User
Joined
Oct 8, 2009
Messages
152
Reaction score
14
Odp: Kasyno - TFS 0.3.6 PL

Dzi?ki ci ;*
Repucik oczywi?cie poleci :p
Skrypt 9.5/10 ( nie podobaj? mi si? efekty xD )
Pozdrawiam :]
 

Kopek14

Advanced User
Joined
May 19, 2008
Messages
226
Reaction score
10
Odp: Kasyno - TFS 0.3.6 PL

Mo?esz mi napisa? gdzie tu zmieni? ile % szans na wygran? bo to:
Code:
-- 5cc  - Chance 50%
to jest chyba tylko komentarz...
 

Mag Egzorcysta

Advanced User
Joined
Apr 17, 2010
Messages
248
Reaction score
39
Odp: Kasyno - TFS 0.3.6 PL

Nie chyba tylko napewno..

Code:
rand = math.random(1,2)

zamieniasz na (x = liczba do ktorej ma losowac)

Code:
rand = math.random(1,x)

Potem w (kolor czerwony):
Code:
            rand = math.random(1,2)
  [B][COLOR="Red"]          if rand == 1 then[/COLOR][/B]
                doRemoveItem(getkasa.uid,5)
                doSendMagicEffect(kasapos,46)
                doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_RED,"You have lost 5 Crystal Coins.")
				return 0
			end
[COLOR="Red"][B]            if rand == 2 then[/B][/COLOR]
                doRemoveItem(getkasa.uid,5)
                doCreateItem(2160,10,winpos)
                doSendMagicEffect(winpos,35)
                doSendMagicEffect(player,27)
                doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,"Congratulations !  You have won 5 Crystal Coins.")
				return 0

Dopisujesz liczby (kt?re wygrywaj? lub przegrywaj?) przyk?adowo:
Code:
 if rand == 2 or [COLOR="Red"]rand == 3 or rand == 4then[/COLOR]

Mam nadzieje, ?e sobie poradzisz.
 

kajbrz

User
Joined
Apr 26, 2009
Messages
24
Reaction score
0
Odp: Kasyno - TFS 0.3.6 PL

@Topic
Skrypt random wylosuje tylko 1 liczb?, wi?c powiniene? u?y? ELSE, gdy? sprawdzanie spowalnia skrypt

9/10
 

Mag Egzorcysta

Advanced User
Joined
Apr 17, 2010
Messages
248
Reaction score
39
Odp: Kasyno - TFS 0.3.6 PL

Na pocz?tku losuje si? liczba.. a potem sprawdza czy wygra?a czy przegra?a.. Skrypt jest dobry. A co do szybko?ci skryptu to r??nice s? w granicach 0.000001 sekundy, wi?c nie wiem komu to robi jak?? r??nic?..
 

quas

New User
Joined
Apr 5, 2008
Messages
8
Reaction score
1
Odp: Kasyno - TFS 0.3.6 PL

PHP:
local config = {
		crystalcoin_id = 2160,
		pozycja = {x=506, y=211, z=6},
		winpos = {x=504, y=211, z=6}
			}
		
local kasa = {
		[5] = {szansa = 10},  --%
		[10] = {szansa = 10},
		[25] = {szansa = 10},
		[50] = {szansa = 10}
		}
function onUse(cid, item, frompos, item2, topos)
	local cc = getTileItemById(config.pozycja,config.crystalcoin_id)
	if((not cc.uid > 0) or (not kasa[cc.type].szansa)) then
		doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_BLUE,"Put 5, 10, 25 or 50 Crystal Coins, if you want to enter the game.")
		return true;
	end
	local udasie = math.random(1,100);
	udasie = udasie <= kasa[cc.type].szansa and true or false;
	if(udasie) then
		doRemoveItem(cc.uid);
		doCreateItem(config.crystalcoin_id,cc.type*2,config.winpos);
		doSendMagicEffect(config.winpos,35)
		doSendMagicEffect(getCreaturePosition(cid),27)
		doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,"Congratulations !  You have won ".. cc.type .." Crystal Coins.")
		return true;
	else
		doRemoveItem(cc.uid)
		doSendMagicEffect(config.pozycja,46)
		doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_RED,"You have lost ".. cc.type .." Crystal Coins.")
		return true;
	end
end

nom.
 

OTS Master

User
Joined
Mar 6, 2009
Messages
13
Reaction score
0
Odp: Kasyno - TFS 0.3.6 PL

@QuaS:

Code:
local config = {cc = 216, pos = {x=506, y=211, z=6}, {x=504, y=211, z=6}}
local kasa = {[5] = 10, [10] = 10, [25] = 10, [50] = 10}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local cc = getTileItemById(config.pozycja,config.crystalcoin_id)
    if(not cc or not kasa[cc.type])) then
        return doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_BLUE,"Put 5, 10, 25 or 50 Crystal Coins, if you want to enter the game.")
    end

    local udasie = math.random(1,100)
    udasie = udasie <= kasa[cc.type] and true or false
    if(udasie) then
        doRemoveItem(cc.uid)
        doCreateItem(config.crystalcoin_id, cc.type * 2, config.winpos)
        doSendMagicEffect(config.winpos, CONST_ME_HEARTS)
        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_GIFT_WRAPS)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Congratulations !  You have won ".. cc.type .." Crystal Coins.")
    else
        doRemoveItem(cc.uid)
        doSendMagicEffect(config.pozycja, CONST_ME_CARNIPHILA)
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "You have lost ".. cc.type .." Crystal Coins.")
    end
	return true
end

Updatniete headery + usuniete zb?dne 2 returny (1 na ko?cu zamiast.) + usuni?te zb?dne ?redniki = less bytes xP!
 

quas

New User
Joined
Apr 5, 2008
Messages
8
Reaction score
1
Odp: Kasyno - TFS 0.3.6 PL

@QuaS:
Code:
local config = {cc = 216, pos = {x=506, y=211, z=6}, {x=504, y=211, z=6}}
local kasa = {[5] = 10, [10] = 10, [25] = 10, [50] = 10}
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local cc = getTileItemById(config.pozycja,config.crystalcoin_id)
    if(not cc or not kasa[cc.type])) then
        return doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_BLUE,"Put 5, 10, 25 or 50 Crystal Coins, if you want to enter the game.")
    end
    local udasie = math.random(1,100)
    udasie = udasie <= kasa[cc.type] and true or false
    if(udasie) then
        doRemoveItem(cc.uid)
        doCreateItem(config.crystalcoin_id, cc.type * 2, config.winpos)
        doSendMagicEffect(config.winpos, CONST_ME_HEARTS)
        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_GIFT_WRAPS)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Congratulations !  You have won ".. cc.type .." Crystal Coins.")
    else
        doRemoveItem(cc.uid)
        doSendMagicEffect(config.pozycja, CONST_ME_CARNIPHILA)
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "You have lost ".. cc.type .." Crystal Coins.")
    end
	return true
end
Updatniete headery + usuniete zb?dne 2 returny (1 na ko?cu zamiast.) + usuni?te zb?dne ?redniki = less bytes xP!

Jak ju? co? robisz, to r?b to dobrze!
PHP:
local config = {cc = 2160, pos = {x=506, y=211, z=6}, winpos ={x=504, y=211, z=6}}
local kasa = {[5] = 10, [10] = 10, [25] = 10, [50] = 10}
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local cc = getTileItemById(config.pos,config.cc)
    if(not cc or not kasa[cc.type])) then
        return doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_BLUE,"Put 5, 10, 25 or 50 Crystal Coins, if you want to enter the game.")
    end
    local udasie = math.random(1,100)
    udasie = udasie <= kasa[cc.type] and true or false
    if(udasie) then
        doRemoveItem(cc.uid)
        doCreateItem(config.cc, cc.type * 2, config.winpos)
        doSendMagicEffect(config.winpos, CONST_ME_HEARTS)
        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_GIFT_WRAPS)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Congratulations !  You have won ".. cc.type .." Crystal Coins.")
    else
        doRemoveItem(cc.uid)
        doSendMagicEffect(config.pos, CONST_ME_CARNIPHILA)
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "You have lost ".. cc.type .." Crystal Coins.")
    end
	return true
end
 

Gremarek

Active User
Joined
Apr 21, 2010
Messages
111
Reaction score
5
Odp: Kasyno - TFS 0.3.6 PL

Skrypt dobry, Ale mo?na by?o by go napisa? bez Komentarzy mniej linijek ;) , Ale to ju? Autora , Sprawa ;)
 

Oskar

Forum friend
Joined
Jan 24, 2009
Messages
2,256
Reaction score
331
Odp: Kasyno - TFS 0.3.6 PL

PHP:
function onUse(cid, item, frompos, itemEx, topos)
local pos = getCreaturePosition(cid)
local config = {
                [6000] = {pos_kaski={x=pos.x+1,y=pos.y,z=pos.z,stackpos=255}, pos_nagrody={x=pos.x+1,y=pos.y+1,z=pos.z}},
                [6001] = {pos_kaski={x=pos.x,y=pos.y+1,z=pos.z,stackpos=255}, pos_nagrody={x=pos.x+1,y=pos.y+1,z=pos.z}},
                [6002] = {pos_kaski={x=pos.x-1,y=pos.y,z=pos.z,stackpos=255}, pos_nagrody={x=pos.x-1,y=pos.y+1,z=pos.z}},
                [6003] = {pos_kaski={x=pos.x,y=pos.y-1,z=pos.z,stackpos=255}, pos_nagrody={x=pos.x+1,y=pos.y-1,z=pos.z}}
                }
local config_2 = {
                [1] = {ile_cc=5, szansa=20, wygrana=15},
                [2] = {ile_cc=10, szansa=15, wygrana=25},
                [3] = {ile_cc=25, szansa=10, wygrana=50},
                [4] = {ile_cc=50, szansa=5, wygrana=100}
                }
local dzwignia = config[item.actionid]
local position_kasy = getThingFromPos(dzwignia.pos_kaski)
local rand = math.random(1,100)
if dzwignia then
    if item.itemid == 1945 then
        if position_kasy.itemid == 2160 then
            for i=1, #config_2 do
            if position_kasy.type == config_2[i].ile_cc then
                if rand >= config_2[i].szansa then
                    doTransformItem(item.uid, item.itemid+1)
                    doRemoveItem(position_kasy.uid, config_2[i].ile_cc)
                    doSendMagicEffect(dzwignia.pos_kaski, 2)
                    doPlayerSendTextMessage(cid, 22, "Straciles "..config_2[i].ile_cc.." Crystal Coins :(.")
                    return true
                else
                    doTransformItem(item.uid, item.itemid+1)
                    doRemoveItem(position_kasy.uid, config_2[i].ile_cc)
                    doCreateItem(2160, config_2[i].wygrana, dzwignia.pos_nagrody)
                    doSendMagicEffect(dzwignia.pos_nagrody, 13)
                    doSendMagicEffect(position_kasy, 21)
                    doPlayerSendTextMessage(cid, 22, "Gratulacje Wygrales "..config_2[i].wygrana.." Crystal Coins :).")
                    return true
                end
            end
            end
        else
            doPlayerSendTextMessage(cid, 22, "Poloz kase.")
            return true
        end
    elseif item.itemid == 1946 then
        doTransformItem(item.uid, item.itemid-1)
    end
end    
return true
end
A tutaj m?j.
 

Gremarek

Active User
Joined
Apr 21, 2010
Messages
111
Reaction score
5
Odp: Kasyno - TFS 0.3.6 PL

Up kolegi Skrypt jest Lepszy ni?, Autora. ;) Wi?c jak by? radze bra? od kolegi UP ;)
 

Mag Egzorcysta

Advanced User
Joined
Apr 17, 2010
Messages
248
Reaction score
39
Odp: Kasyno - TFS 0.3.6 PL

Oczywi?cie oskara lepszy, heh - Ma lepszy config. :)

Wklej? go w pierwszego posta za pozwoleniem..
Pisa?em to kasyno jak si? uczy?em .lua xD
 

Don Makos

Advanced User
Joined
Aug 26, 2009
Messages
178
Reaction score
8
Odp: Kasyno - TFS 0.3.6 PL

Dzi?ki, dobry skrypt. U mnie all dzia?a.
 
Status
Not open for further replies.
Top