• logo_cipsoft
    Nowe serwery zostały otwarte 19 Lut 2025:
    Noctalia (Open PvP) Ignitera (Open PvP) us_logo Xybra (Open PvP)

Creaturescripts Events! Automatyczne dodawanie punktow do sms shopu.

Status
Zamknięty.

Unass

Active User
Dołączył
Lipiec 21, 2010
Posty
123
Liczba reakcji
22
Skrypt polega na automatycznym przyznawianiu Premium Punktow do sms shopu za osiagniecia na serwerze. Przykladowo pierwsza osoba, kt?ra osi?gnie 80 sword fighting otrzyma 100 Premium Points. Podobnie jest z shieldingiem, levelem, axe, club i distance fightingiem.

PHP:
20:16 Congratulations! You are first player with 80 sword fighting and you have gained 100 Premium Points!

Przejdzmy do rzeczy..

Najpierw musimy zaj?c sie funkcj?, kt?ra bedzie dodawala punkty do konta.
W tym celu wchodzimy w data/lib i otwieramy plik functions.lua , po czym na koncu dodajemy:

PHP:
function doAddPoints(cid, points)
    db.executeQuery("UPDATE `accounts` SET `premium_points` = `premium_points` + " .. points .. " WHERE `id` = " .. getPlayerAccountId(cid) .. ";")
end

Nastepnie wchodzimy w data/creaturescripts/scripts i tworzymy plik o nazwie events.lua
PHP:
			--Script By Unass--
local skills = 
{
	[1] = {points = 100, storage = 30701, value = 2, text = "club fighting", level = 80},
	[2] = {points = 100, storage = 30702, value = 2, text = "sword fighting", level = 80},
	[3] = {points = 100, storage = 30703, value = 2, text = "axe fighting", level = 80},
	[4] = {points = 100, storage = 30704, value = 2, text = "distance fighting", level = 80},
	[5] = {points = 100, storage = 30705, value = 2, text = "shielding", level = 80},
	[8] = {points = 100, storage = 30706, value = 2, text = "level", level = 100}
}

function onAdvance(cid, skill, oldLevel, newLevel)
	local x = skills[skill]
	if getGlobalStorageValue(x.storage) < x.value and getPlayerStorageValue(cid, x.storage) ~= x.value and getPlayerSkillLevel(cid, skill) >= x.level and skills[skill] then
	doAddPoints(cid, x.points)
	setGlobalStorageValue(x.storage, x.value)
	setPlayerStorageValue(cid, x.storage, x.value)
	doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Congratulations! You are first player with ".. x.level .." ".. x.text .." and you have gained ".. x.points .." Premium Points!")
	end
	return true
end

Musimy zarejestrowac to w creaturescripts.xml
PHP:
<event type="advance" name="Events" event="script" value="events.lua"/>

oraz w login.lua
registerCreatureEvent(cid, "Events")


Skrypt napisany w 100% przeze mnie. W razie wszelakich pyta? piszcie na dole.
 
Odp: Events! Automatyczne dodawanie punktow do sms shopu.

#Up

Zmieniasz tylko zawarto?? skryptu events.lua na to :
PHP:
            --Script By Unass--
local skills = 
{
    [1] = {points = 100, storage = 30701, value = 2, text = "club fighting", level = 80},
    [2] = {points = 100, storage = 30702, value = 2, text = "sword fighting", level = 80},
    [3] = {points = 100, storage = 30703, value = 2, text = "axe fighting", level = 80},
    [4] = {points = 100, storage = 30704, value = 2, text = "distance fighting", level = 80},
    [5] = {points = 100, storage = 30705, value = 2, text = "shielding", level = 80},
    [8] = {points = 100, storage = 30706, value = 2, text = "level", level = 100}
    [9] = {points = 100, storage = 30707  value = 2, text = "magic level", level = 80}
}

function onAdvance(cid, skill, oldLevel, newLevel)
    local x = skills[skill]
    if getGlobalStorageValue(x.storage) < x.value and getPlayerStorageValue(cid, x.storage) ~= x.value and getPlayerSkillLevel(cid, skill) >= x.level and skills[skill] then
    doAddPoints(cid, x.points)
    setGlobalStorageValue(x.storage, x.value)
    setPlayerStorageValue(cid, x.storage, x.value)
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Congratulations! You are first player with ".. x.level .." ".. x.text .." and you have gained ".. x.points .." Premium Points!")
    end
    return true
end

(?)

#Temat

Skrypt jak najbardziej przydatny i pomys?owy. Osobi?cie z niego korzystam i jestem zadowolony.​
 
Ostatnia edycja:
Odp: Events! Automatyczne dodawanie punktow do sms shopu.

Kr?tki, przydatny, ciekawy. Fajnie by mog?o by? r?wnie? bardziej rozbudowanie: dla pierwszej osoby 50 pkt, dla drugiej 30, a dla trzeciej 10, lub co? w tym stylu. ^^

Tak czy tak pomys? bardzo mi si? podoba. W pe?ni zautomatyzowany, co oszcz?dza pracy w?adzom serwera, je?li chc? zrobi? co? podobnego. :)
 
Odp: Events! Automatyczne dodawanie punktow do sms shopu.

Yo!
Postara?em si? troch? i napisa?em skrypt od nowa dodaj?c par? funkcji... Jednak nie mia?em czasu na dokonanie test?w, je?li b?dzie on wadliwy prosz? o PW z wynikiem z konsoli a ja poprawi? ewentualne b??dy :).
PHP:
function adamsiqReturnStorage(st) -- Aby nie zwracalo ujemnych wartosci :)
if st < 0 then
return 0 
else
return st
end
function adamsiqAddPlayerPoints(cid,points)
db.executeQuery("UPDATE `accounts` SET `premium_points` = `premium_points` + " .. points .. " WHERE `id` = " .. getPlayerAccountId(cid) .. ";")
end
--- onAdvance
function onAdvance(cid, skill, oldLevel, newLevel)
--- onAdvance
--AdamsiQ Works!
local skillsNames = {
[1] = "club fighting",
[2] = "sword fighting",
[3] = "axe foghting",
[4] = "distance fighting",
[5] = "shielding",
[8] = "level",
[9] = "magic level"
}
local nagrody = {
[1] = { -- Nagrody dla pierwszego gracza
 [1] = {ptk = 100, items = {{2160,10}}, minLevel = 100, storage = 1230001},
 [2] = {ptk = 100, items = {{2160,10}}, minLevel = 100, storage = 1230002},
 [3] = {ptk = 100, items = {{2160,10}}, minLevel = 100, storage = 1230003},
 [4] = {ptk = 100, items = {{2160,10}}, minLevel = 100, storage = 1230004},
 [5] = {ptk = 100, items = {{2160,10}}, minLevel = 100, storage = 1230005},
 [8] = {ptk = 100, items = {{2160,5}},  minLevel = 100, storage = 1230006},
 [9] = {ptk = 100, items = {{2160,10}}, minLevel = 100, storage = 1230007}
},
[2] = {
 [1] = {ptk = 50, items = {{2160,5}}, minLevel = 100, storage = 1230001},
 [2] = {ptk = 50, items = {{2160,5}}, minLevel = 100, storage = 1230002},
 [3] = {ptk = 50, items = {{2160,5}}, minLevel = 100, storage = 1230003},
 [4] = {ptk = 50, items = {{2160,5}}, minLevel = 100, storage = 1230004},
 [5] = {ptk = 50, items = {{2160,5}}, minLevel = 100, storage = 1230005},
 [8] = {ptk = 50, items = {{2160,3}}, minLevel = 100, storage = 1230006},
 [9] = {ptk = 50, items = {{2160,5}}, minLevel = 100, storage = 1230007}
},
[3] = {
 [1] = {ptk = 25, items = {{2160,1}}, minLevel = 100, storage = 1230001},
 [2] = {ptk = 25, items = {{2160,1}}, minLevel = 100, storage = 1230002},
 [3] = {ptk = 25, items = {{2160,1}}, minLevel = 100, storage = 1230003},
 [4] = {ptk = 25, items = {{2160,1}}, minLevel = 100, storage = 1230004},
 [5] = {ptk = 25, items = {{2160,1}}, minLevel = 100, storage = 1230005},
 [8] = {ptk = 25, items = {},  	      minLevel = 100, storage = 1230006},
 [9] = {ptk = 25, items = {{2160,1}}, minLevel = 100, storage = 1230007}
}
}
local second_storages = {
 [1] = 1230021,
 [2] = 1230022,
 [3] = 1230023,
 [4] = 1230024,
 [5] = 1230025,
 [8] = 1230026,
 [9] = 1230027
}

local name = skillsNames[skill]
if oldLevel < newLevel then
 for i = 1, #nagrody do
  local load = nagrody[i][skill]
  local st = adamsiqReturnStorage(getGlobalStorageValue(load.storage))
  local countes = {"first", "second", "third"}
  local lala = countes[st]
  if st <= i and adamsiqReturnStorage(getPlayerStorageValue(cid,second_storages[skill])) < 0 then
   if newLevel >= load.minLevel then
    if getPlayerGroupId(cid) < 3 then
     setPlayerStorageValue(cid,second_storages[skill],1)
     setGlobalStorageValue(load.storage,st+1)
     doPlayerSendTextMessage(cid,19,"You are a "..lala.." player who got a "..newLevel.." of "..name.."! You get a small prize!")
     if load.ptk > 0 then
     adamsiqAddPlayerPoints(cid,load.ptk)
     end
     if #load.items > 0 then
      for b = 1, #load.items do
       doPlayerAddItem(cid,load.items[b][1], load.items[b][2] or 1)
      end
     end
     return true
    end
   end 
  end
 end
end
return true
end
 
Ostatnia edycja:
Odp: Events! Automatyczne dodawanie punktow do sms shopu.

Unass Wszystko dziala! :) thx, reput leci..
 
Odp: Events! Automatyczne dodawanie punktow do sms shopu.

mi to nie dzala posiadam silnik alissow 4.11 i wywala b?ad:

[24/12/2010 11:01:56] [Error - LuaScriptInterface::loadFile] data/creaturescripts/scripts/events.lua:13: 'then' expected near '='
[24/12/2010 11:01:56] [Warning - Event::loadScript] Cannot load script (data/creaturescripts/scripts/events.lua)
[24/12/2010 11:01:56] data/creaturescripts/scripts/events.lua:13: 'then' expected near '='
 
Odp: Events! Automatyczne dodawanie punktow do sms shopu.

b?ad w konsoli pomijajac te ktore sam naprawilem local st = adamsiqReturnStorage(getGlobalStorageValue(load.st orage)) i inne
ale nie wiem ocb z tym
[6:54:33.561] [Error - LuaInterface::loadFile] data/creaturescripts/scripts/events.lua:90: 'end' expected (to close 'function' at line 1) near '<eof>'
[6:54:33.561] [Warning - Event::loadScript] Cannot load script (data/creaturescripts/scripts/events.lua)
[6:54:33.561] data/creaturescripts/scripts/events.lua:90: 'end' expected (to close 'function' at line 1) near '<eof>'
 
Odp: Events! Automatyczne dodawanie punktow do sms shopu.

Wiec chcialem napisac 2 rzeczy :D

1.
5639160900_1398476280.png


2. Pewnie nawet nie sprawdziles skryptu tylko nabiles post i powiem Ci ze on nie dziala jak nie usuniesz spacji i nie dodasz enda ;P
Poprawiony kod jak by ktorys z odkopujacych chcial :P
Kod:
function adamsiqReturnStorage(st) -- Aby nie zwracalo ujemnych wartosci :)
if st < 0 then
return 0 
else
return st
end
end

function adamsiqAddPlayerPoints(cid,points)
db.executeQuery("UPDATE `accounts` SET `premium_points` = `premium_points` + " .. points .. " WHERE `id` = " .. getPlayerAccountId(cid) .. ";")
end

--- onAdvance
function onAdvance(cid, skill, oldLevel, newLevel)
--- onAdvance
--AdamsiQ Works!
local skillsNames = {
[1] = "club fighting",
[2] = "sword fighting",
[3] = "axe foghting",
[4] = "distance fighting",
[5] = "shielding",
[8] = "level",
[9] = "magic level"
}

local nagrody = {
[1] = { -- Nagrody dla pierwszego gracza
 [1] = {ptk = 100, items = {{2160,10}}, minLevel = 100, storage = 1230001},
 [2] = {ptk = 100, items = {{2160,10}}, minLevel = 100, storage = 1230002},
 [3] = {ptk = 100, items = {{2160,10}}, minLevel = 100, storage = 1230003},
 [4] = {ptk = 100, items = {{2160,10}}, minLevel = 100, storage = 1230004},
 [5] = {ptk = 100, items = {{2160,10}}, minLevel = 100, storage = 1230005},
 [8] = {ptk = 100, items = {{2160,5}},  minLevel = 100, storage = 1230006},
 [9] = {ptk = 100, items = {{2160,10}}, minLevel = 100, storage = 1230007}
},
[2] = {
 [1] = {ptk = 50, items = {{2160,5}}, minLevel = 100, storage = 1230001},
 [2] = {ptk = 50, items = {{2160,5}}, minLevel = 100, storage = 1230002},
 [3] = {ptk = 50, items = {{2160,5}}, minLevel = 100, storage = 1230003},
 [4] = {ptk = 50, items = {{2160,5}}, minLevel = 100, storage = 1230004},
 [5] = {ptk = 50, items = {{2160,5}}, minLevel = 100, storage = 1230005},
 [8] = {ptk = 50, items = {{2160,3}}, minLevel = 100, storage = 1230006},
 [9] = {ptk = 50, items = {{2160,5}}, minLevel = 100, storage = 1230007}
},
[3] = {
 [1] = {ptk = 25, items = {{2160,1}}, minLevel = 100, storage = 1230001},
 [2] = {ptk = 25, items = {{2160,1}}, minLevel = 100, storage = 1230002},
 [3] = {ptk = 25, items = {{2160,1}}, minLevel = 100, storage = 1230003},
 [4] = {ptk = 25, items = {{2160,1}}, minLevel = 100, storage = 1230004},
 [5] = {ptk = 25, items = {{2160,1}}, minLevel = 100, storage = 1230005},
 [8] = {ptk = 25, items = {},  	      minLevel = 100, storage = 1230006},
 [9] = {ptk = 25, items = {{2160,1}}, minLevel = 100, storage = 1230007}
}
}

local second_storages = {
 [1] = 1230021,
 [2] = 1230022,
 [3] = 1230023,
 [4] = 1230024,
 [5] = 1230025,
 [8] = 1230026,
 [9] = 1230027
}
 
local name = skillsNames[skill]
if oldLevel < newLevel then
 for i = 1, #nagrody do
  local load = nagrody[i][skill]
  local st = adamsiqReturnStorage(getGlobalStorageValue(load.storage))
  local countes = {"first", "second", "third"}
  local lala = countes[st]
  if st <= i and adamsiqReturnStorage(getPlayerStorageValue(cid,second_storages[skill])) < 0 then
   if newLevel >= load.minLevel then
    if getPlayerGroupId(cid) < 3 then
     setPlayerStorageValue(cid,second_storages[skill],1)
     setGlobalStorageValue(load.storage,st+1)
     doPlayerSendTextMessage(cid,19,"You are a "..lala.." player who got a "..newLevel.." of "..name.."! You get a small prize!")
     if load.ptk > 0 then
     adamsiqAddPlayerPoints(cid,load.ptk)
     end
     if #load.items > 0 then
      for b = 1, #load.items do
       doPlayerAddItem(cid,load.items[b][1], load.items[b][2] or 1)
      end
     end
     return true
    end
   end 
  end
 end
end
return true
end
 
Status
Zamknięty.
Do góry