Ich hoffe euch gefällt es umso mehr, viel spaß damit.
2 Quests, Extrahieren und steine entfernen
Extrahieren: manche items lassen sich nicht aufeinander ziehen, also zb 20 seelis auf 40, deshalb die quest,
neue funktion in die questlib.lua eintragen und der name in quest_funcions
Steine Entfernen, sie entfernt steine und lässt sie in der Auswahl anzeigen, Splittersteine werden nicht mit angezeigt
PHP Code:
function pc.give_item3(vnum,count,solo)
local count,num = count or 1,solo == true and 1 or 200
while count > 0 do
pc.give_item2(vnum, math.min(num,count))
count = count-num;
end
end
PHP Code:
quest stein_extra begin
state start begin
when 20006.take with item.has_flag(4) begin--items extrahieren
--[[Es werden nur Items extrahiert die man Stapeln kann, sonst wäre die Quest sinnlos]]
say_title(mob_name(npc.get_race()))
say()
local vnum=item.get_vnum()
local black_list={19,11,10,12,13,14,15,16,17,18}
--[[Hier kommen alle Item's wo die Spieler beim extrahieren vorteile erzielen,
wie zb stapelbare EXP Ringe]]
for i=1,table.getn(black_list) do
if black_list[i]==vnum then
say('Du kannst diese Item nicht extrahieren')
return
end
end
say('Möchtest du')
say()
say_item_vnum(vnum)
say('Extrahieren?')
say()
if select('Extrahieren','Abbrechen')==2 then return end
local count= pc.count_item(vnum)
pc.remove_item(vnum,count)
pc.give_item3(vnum,count)--[[
pc.give_item3 muss vorhanden sein,
ist im forum zusehen]]
end
when 20006.take begin -- steine entfernen
say_title(mob_name(20006))
say()
if not ((item.get_type() == 1 and item.get_sub_type() < 6) or (item.get_type() == 2 and item.get_sub_type() == 0)) then
say('Du kannst nur bei Rüstungen und Waffen gesteine entfernen')
return
end
local data,x = {{},{}},1
for i = 0,2 do
local c = item.get_socket(i)
if c > 2 and c ~= 28960 then
data[1][x],data[2][x]= i,item_name(c)
x = x + 1
end
end
if data[1][1]==nil then say('Es gibt keine Gesteine') return end
table.insert(data[2],'Abbrechen')
say('Welchen Stein möchtest du entfernen?')
local s=select_table(data[2])
if s==table.getn(data[2]) then return end
say(data[2][s]..' Entfernen?')
if select('Ja','Nein')==2 then return end
say(data[2][s].." Entfernt")
pc.give_item2(item.get_socket(data[1][s]),1)
item.set_socket(data[1][s],28960)
end
end
end
Die Bank quest, sie arbeitet ohne Mysql und ohne Questflags, man kann sich unendlich viele Konten erstellen, die Konten sind Global dh. man kann mit alle chars im acc zum Konto zugreifen, Geld abheben und einzahlen sowie ein Transfer von Konto zu Konto ist möglich.
Die Funktionen die man braucht.
PHP Code:
local function exportstring( s )
return string.format("%q", s)
end
function table.save( tbl,filename )
local charS,charE = " ","\n"
local file,err = io.open( filename, "wb" )
if err then return err end
local tables,lookup = { tbl },{ [tbl] = 1 }
file:write( "return {"..charE )
for idx,t in ipairs( tables ) do
file:write( "-- Table: {"..idx.."}"..charE )
file:write( "{"..charE )
local thandled = {}
for i,v in ipairs( t ) do
thandled[i] = true
local stype = type( v )
if stype == "table" then
if not lookup[v] then
table.insert( tables, v )
lookup[v] = table.getn(tables)
end
file:write( charS.."{"..lookup[v].."},"..charE )
elseif stype == "string" then
file:write( charS..exportstring( v )..","..charE )
elseif stype == "number" then
file:write( charS..tostring( v )..","..charE )
end
end
for i,v in pairs( t ) do
if (not thandled[i]) then
local str = ""
local stype = type( i )
if stype == "table" then
if not lookup[i] then
table.insert( tables,i )
lookup[i] = table.getn(tables)
end
str = charS.."[{"..lookup[i].."}]="
elseif stype == "string" then
str = charS.."["..exportstring( i ).."]="
elseif stype == "number" then
str = charS.."["..tostring( i ).."]="
end
if str ~= "" then
stype = type( v )
if stype == "table" then
if not lookup[v] then
table.insert( tables,v )
lookup[v] = table.getn(tables)
end
file:write( str.."{"..lookup[v].."},"..charE )
elseif stype == "string" then
file:write( str..exportstring( v )..","..charE )
elseif stype == "number" then
file:write( str..tostring( v )..","..charE )
end
end
end
end
file:write( "},"..charE )
end
file:write( "}" )
file:close()
end
function table.load( sfile )
local ftables,err = loadfile( sfile )
if err then return _,err end
local tables = ftables()
for idx = 1,table.getn(tables) do
local tolinki = {}
for i,v in pairs( tables[idx] ) do
if type( v ) == "table" then
tables[idx][i] = tables[v[1]]
end
if type( i ) == "table" and tables[i[1]] then
table.insert( tolinki,{ i,tables[i[1]] } )
end
end
for _,v in ipairs( tolinki ) do
tables[idx][v[2]],tables[idx][v[1]] = tables[idx][v[1]],nil
end
end
return tables[1]
end
hier die Quest
PHP Code:
quest bank_q begin
state start begin
when 9009.chat.'Bank' begin
say_title(mob_name(npc.get_race()))
say()
local path='/usr/home/game/share/locale/germany/quest/Spieler/Bank.lua'
if table.load(path)==nil then
table.save({},path)
end
local a=select('Bankkonto erstellen','Konto Status','Abbrechen')
if a==3 then return end --abbrechen
if a==1 then --konto erstellen
say_title(mob_name(npc.get_race()))
say()
say('Schritt 1.')
say('Gib eine id ein, diese ID brauchst [ENTER]du um dein Konto zu öffnen')
local id=input()
say_title(mob_name(npc.get_race()))
say()
local tabelle=table.load(path)
if type(tabelle[id])=='table' then
say('Diese id ist schon vorhanden, [ENTER]du kannst sie nicht benutzen')
return
end
say('Schritt 2.')
say('Gib dein persönliches Passwort ein')
local pw=input()
if pw=='' or pw==nil then say('Fehlerhafte eingabe') return end
tabelle[id]={0,pw}
table.save(tabelle,path)
say_title(mob_name(npc.get_race()))
say()
say('Konto erfolgreich erstellt')
elseif a==2 then --konto status
say_title(mob_name(npc.get_race()))
say()
local s= select('Passwort Bearbeiten','Geld Einzahlen','Geld Abheben','Geld Senden','Aktuelles Guthaben','Abbrechen')
if s==6 then return end
say_title(mob_name(npc.get_race()))
say()
say('Gib die Id deines Kontos ein!')
local id=input()
say_title(mob_name(npc.get_race()))
say()
local a= table.load(path)
if a[id]==nil then
say('Es gibt kein konto mit dieser ID')
return
end
if a[id][2]~=nil then
say('Dieses Konto ist mit einem Passwort geschützt, gib ihn ein.')
eingabe=input()
if a[id][2]~=eingabe then
local b,m= a[id][3] and a[id][3]+1 or 1,a[id][1]
a[id]={m,a[id][2],b}
table.save(a,path)
say('Die eingabe: '..eingabe..' [ENTER]Stimmt mit dem Passwort nicht überein')
say(b..' x wurde das Passwort falsch eingegeben')
return
end
end
if a[id][3]~=nil then
say_title(mob_name(npc.get_race()))
say()
say('Man hat versucht dein passwort zu knacken')
say('Wir Empfehlen dein Passwort zu Ändern.')
say(a[id][3]..' Falsch eigegebenes Passwort')
a[id]={a[id][1],eingabe}
table.save(a,path)
wait()
end
if s==1 then --passwort bearbeiten
say('Was möchtest du machen?')
if select("Passwort Bearbeiten","Abbrechen")==2 then return end
say('Wie soll das neue Pw lauten?')
say('altes pw: '..(a[id][2] or ''))
local npw=input()
say_title(mob_name(npc.get_race()))
say()
if npw==a[id][2] then say('es ist das selbe Passwort') return end
say(npw..' durch '..(a[id][2] or '')..' ersetzten?')
if select('Ja','Nein')==2 then return end
say_title(mob_name(npc.get_race()))
say()
local geld= a[id][1]
a[id]={geld,npw}
table.save(a,path)
say('Du hast das Passwort erfolgreich geändert.')
elseif s==2 then -- geld einzahlen
local geld= a[id][1]
say_title(mob_name(npc.get_race()))
say()
say('Guthaben: '..a[id][1]..' Yang')
say()
say('Möchtest du Geld auf das Konto einzahlen?')
if select('Ja','Nein')==2 then return end
say_title(mob_name(npc.get_race()))
say()
say('Aktuelles Guthaben: '..geld..' yang')
say('Gib die Menge ein die du Einzahlen möchtest')
local menge=math.abs(input())
if not tonumber(menge) then say('Es dürfen nur Zahlen enthalten') return end
if tonumber(menge)>pc.get_money() then say('soviel geld hast du nicht bei dir.') return end
if menge=='' then say('Die Eingabe darf nicht 0 sein') return end
pc.change_money(-tonumber(menge))
a[id]={(geld+menge),eingabe}
table.save(a,path)
say_title(mob_name(npc.get_race()))
say()
say('Du hast erfolgreich '..menge..' Yang auf deinem Konto eingezahlt')
elseif s==3 then --geld abheben
say_title(mob_name(npc.get_race()))
say()
say('Guthaben: '..a[id][1]..' Yang')
say()
say('Gib die menge ein die du abheben möchtest')
local menge=math.abs(input())
if not tonumber(menge) then say('Es dürfen nur Zahlen enthalten') return end
if menge> a[id][1] then say('Du hast nicht soviel Guthaben auf deinem Konto.') return end
if pc.get_money()+menge >2e9-1 then say('Soviel geld kannst du nicht tragen') return end
pc.change_money(menge)
a[id]={(a[id][1]-menge),eingabe}
table.save(a,path)
say_title(mob_name(npc.get_race()))
say()
say('Du hast '..menge..' Yang erhalten')
elseif s==4 then --geld senden
say_title(mob_name(npc.get_race()))
say()
say('Gib die Id des Kontos ein, dem du Geld [ENTER]senden willst.')
local id2=input()
if a[id2]==nil then say('Es gibt kein Konto mit dieser ID') return end
say_title(mob_name(npc.get_race()))
say()
say('Gib die Menge ein die du senden willst')
local menge=math.abs(input())
if not tonumber(menge) then say('Es dürfen nur Zahlen enthalten') return end
if menge> a[id][1] then say('Du hast nicht soviel Guthaben auf deinem Konto.') return end
if menge =='' then say('Falsche eingabe') return end
if a[id2][3]==nil then
a[id2]={(a[id2][1]+menge),a[id2][2]}
else
a[id2]={(a[id2][1]+menge),a[id2][2],a[id2][3]}
end
a[id]={(a[id][1]-menge),a[id][2]}
table.save(a,path)
say_title(mob_name(npc.get_race()))
say()
say('dein Guthaben nach der transaktion: '..table.load(path)[id][1]..' yang')
say('Du hast erfolgreich '..menge..' gesendet')
elseif s==5 then
say_title(mob_name(npc.get_race()))
say()
say('Dein aktuelles Guthaben Beträgt')
say(a[id][1]..' Yang')
end
end
end
end
end
viel spaß und ich hoffe ihr respektiert meine Arbeit
special thx an Mijago ;-*
Mfg Noa






