· 8 years ago · Dec 04, 2017, 07:48 PM
1[b]Bueno, este es el elf war system script exclusivo para los donadores de blacktibia, igual a rl, solo que se necesita el exe del tfs ya oficial para hacer funcionar los escudos y el sistema correctamente, bueno empesemos:
2
3Ve a globalevents/scripts y crea un archivo con extension de lua llamado start.lua, de ahi pon esto adentro de el:[/b]
4
5[code]function onStartup()
6db.executeQuery("UPDATE `players` SET `online` = 0 WHERE `world_id` = " .. getConfigValue('worldId') .. ";")
7db.executeQuery("DELETE FROM `guild_wars` WHERE `status` = 0 AND `begin` < " .. (os.time() - 2 * 86400) .. ";")
8db.executeQuery("UPDATE `guild_wars` SET `status` = 5, `end` = " .. os.time() .. " WHERE `status` = 1 AND `end` > 0 AND `end` < " .. os.time() .. ";")
9return true
10end[/code]
11
12[b]y en globalevents.xml se pone esto:[/b]
13
14[code]<globalevent name="serverstart" type="start" event="script" value="start.lua"/>[/code]
15
16[b]Despues de eso ve a el lib y ve al 000-constant, abrelo y agrega esto:[/b]
17
18[code]WAR_GUILD = 0
19WAR_ENEMY = 1[/code]
20
21[b]Despues se va a la carpeta llamada talkactions, y creas dos archivos con extension lua, uno llamado balance y otro llamado war, y de ahi agregas lo siguiente:
22
23Balance.lua:[/b]
24[code]local function isValidMoney(value)
25if(value == nil) then
26return false
27end
28
29return (value > 0 and value <= 99999999999999)
30end
31
32function onSay(cid, words, param, channel)
33local guild = getPlayerGuildId(cid)
34if(guild == 0) then
35return false
36end
37
38local t = string.explode(param, ' ', 1)
39if(getPlayerGuildLevel(cid) == GUILDLEVEL_LEADER and isInArray({ 'pick' }, t[1])) then
40if(t[1] == 'pick') then
41local money = { tonumber(t[2]) }
42if(not isValidMoney(money[1])) then
43doPlayerSendChannelMessage(cid, '', 'Invalid amount of money specified.', TALKTYPE_CHANNEL_W, 0)
44return true
45end
46
47local result = db.getResult('SELECT `balance` FROM `guilds` WHERE `id` = ' .. guild)
48if(result:getID() == -1) then
49return false
50end
51
52money[2] = result:getDataLong('balance')
53result:free()
54
55if(money[1] > money[2]) then
56doPlayerSendChannelMessage(cid, '', 'The balance is too low for such amount.', TALKTYPE_CHANNEL_W, 0)
57return true
58end
59
60if(not db.executeQuery('UPDATE `guilds` SET `balance` = `balance` - ' .. money[1] .. ' WHERE `id` = ' .. guild .. ' LIMIT 1;')) then
61return false
62end
63
64doPlayerAddMoney(cid, money[1])
65doPlayerSendChannelMessage(cid, '', 'You have just picked ' .. money[1] .. ' money from your guild balance.', TALKTYPE_CHANNEL_W, 0)
66else
67doPlayerSendChannelMessage(cid, '', 'Invalid sub-command.', TALKTYPE_CHANNEL_W, 0)
68end
69elseif(t[1] == 'donate') then
70local money = tonumber(t[2])
71if(not isValidMoney(money)) then
72doPlayerSendChannelMessage(cid, '', 'Invalid amount of money specified.', TALKTYPE_CHANNEL_W, 0)
73return true
74end
75
76if(getPlayerMoney(cid) < money) then
77doPlayerSendChannelMessage(cid, '', 'You don\'t have enough money.', TALKTYPE_CHANNEL_W, 0)
78return true
79end
80
81if(not doPlayerRemoveMoney(cid, money)) then
82return false
83end
84
85db.executeQuery('UPDATE `guilds` SET `balance` = `balance` + ' .. money .. ' WHERE `id` = ' .. guild .. ' LIMIT 1;')
86doPlayerSendChannelMessage(cid, '', 'You have transfered ' .. money .. ' money to your guild balance.', TALKTYPE_CHANNEL_W, 0)
87else
88local result = db.getResult('SELECT `name`, `balance` FROM `guilds` WHERE `id` = ' .. guild)
89if(result:getID() == -1) then
90return false
91end
92
93doPlayerSendChannelMessage(cid, '', 'Current balance of guild ' .. result:getDataString('name') .. ' is: ' .. result:getDataLong('balance') .. ' bronze coins.', TALKTYPE_CHANNEL_W, 0)
94result:free()
95end
96
97return true
98end[/code]
99
100[b]War.lua[/b]
101
102[code]
103function onSay(cid, words, param, channel)
104local guild = getPlayerGuildId(cid)
105if(not guild or getPlayerGuildLevel(cid) < GUILDLEVEL_LEADER) then
106doPlayerSendChannelMessage(cid, "", "You cannot execute this talkaction.", TALKTYPE_CHANNEL_W, 0)
107return true
108end
109
110local t = string.explode(param, ",")
111if(not t[2]) then
112doPlayerSendChannelMessage(cid, "", "Not enough param(s).", TALKTYPE_CHANNEL_W, 0)
113return true
114end
115
116local enemy = getGuildId(t[2])
117if(not enemy) then
118doPlayerSendChannelMessage(cid, "", "Guild \"" .. t[2] .. "\" does not exists.", TALKTYPE_CHANNEL_W, 0)
119return true
120end
121
122if(enemy == guild) then
123doPlayerSendChannelMessage(cid, "", "You cannot perform war action on your own guild.", TALKTYPE_CHANNEL_W, 0)
124return true
125end
126
127local enemyName, tmp = "", db.getResult("SELECT `name` FROM `guilds` WHERE `id` = " .. enemy)
128if(tmp:getID() ~= -1) then
129enemyName = tmp:getDataString("name")
130tmp:free()
131end
132
133if(isInArray({"accept", "reject", "cancel"}, t[1])) then
134local query = "`guild_id` = " .. enemy .. " AND `enemy_id` = " .. guild
135if(t[1] == "cancel") then
136query = "`guild_id` = " .. guild .. " AND `enemy_id` = " .. enemy
137end
138
139tmp = db.getResult("SELECT `id`, `begin`, `end`, `payment` FROM `guild_wars` WHERE " .. query .. " AND `status` = 0")
140if(tmp:getID() == -1) then
141doPlayerSendChannelMessage(cid, "", "Currently there's no pending invitation for a war with " .. enemyName .. ".", TALKTYPE_CHANNEL_W, 0)
142return true
143end
144
145if(t[1] == "accept") then
146local _tmp = db.getResult("SELECT `balance` FROM `guilds` WHERE `id` = " .. guild)
147local state = _tmp:getID() < 0 or _tmp:getDataInt("balance") < tmp:getDataInt("payment")
148
149_tmp:free()
150if(state) then
151doPlayerSendChannelMessage(cid, "", "Your guild balance is too low to accept this invitation.", TALKTYPE_CHANNEL_W, 0)
152return true
153end
154
155db.executeQuery("UPDATE `guilds` SET `balance` = `balance` - " .. tmp:getDataInt("payment") .. " WHERE `id` = " .. guild)
156end
157
158query = "UPDATE `guild_wars` SET "
159local msg = "accepted " .. enemyName .. " invitation to war."
160if(t[1] == "reject") then
161query = query .. "`end` = " .. os.time() .. ", `status` = 2"
162msg = "rejected " .. enemyName .. " invitation to war."
163elseif(t[1] == "cancel") then
164query = query .. "`end` = " .. os.time() .. ", `status` = 3"
165msg = "canceled invitation to a war with " .. enemyName .. "."
166else
167query = query .. "`begin` = " .. os.time() .. ", `end` = " .. (tmp:getDataInt("end") > 0 and (os.time() + ((tmp:getDataInt("begin") - tmp:getDataInt("end")) / 86400)) or 0) .. ", `status` = 1"
168end
169
170query = query .. " WHERE `id` = " .. tmp:getDataInt("id")
171if(t[1] == "accept") then
172doGuildAddEnemy(guild, enemy, tmp:getDataInt("id"), WAR_GUILD)
173doGuildAddEnemy(enemy, guild, tmp:getDataInt("id"), WAR_ENEMY)
174end
175
176tmp:free()
177db.executeQuery(query)
178doBroadcastMessage(getPlayerGuildName(cid) .. " has " .. msg, MESSAGE_EVENT_ADVANCE)
179return true
180end
181
182if(t[1] == "invite") then
183local str = ""
184tmp = db.getResult("SELECT `guild_id`, `status` FROM `guild_wars` WHERE `guild_id` IN (" .. guild .. "," .. enemy .. ") AND `enemy_id` IN (" .. enemy .. "," .. guild .. ") AND `status` IN (0, 1)")
185if(tmp:getID() ~= -1) then
186if(tmp:getDataInt("status") == 0) then
187if(tmp:getDataInt("guild_id") == guild) then
188str = "You have already invited " .. enemyName .. " to war."
189else
190str = enemyName .. " have already invited you to war."
191end
192else
193str = "You are already on a war with " .. enemyName .. "."
194end
195
196tmp:free()
197end
198
199if(str ~= "") then
200doPlayerSendChannelMessage(cid, "", str, TALKTYPE_CHANNEL_W, 0)
201return true
202end
203
204local frags = tonumber(t[3])
205if(frags ~= nil) then
206frags = math.max(10, math.min(1000, frags))
207else
208frags = 100
209end
210
211local payment = tonumber(t[4])
212if(payment ~= nil) then
213payment = math.max(100000, math.min(1000000000, payment))
214tmp = db.getResult("SELECT `balance` FROM `guilds` WHERE `id` = " .. guild)
215
216local state = tmp:getID() < 0 or tmp:getDataInt("balance") < payment
217tmp:free()
218if(state) then
219doPlayerSendChannelMessage(cid, "", "Your guild balance is too low for such payment.", TALKTYPE_CHANNEL_W, 0)
220return true
221end
222
223db.executeQuery("UPDATE `guilds` SET `balance` = `balance` - " .. payment .. " WHERE `id` = " .. guild)
224else
225payment = 0
226end
227
228local begining, ending = os.time(), tonumber(t[5])
229if(ending ~= nil and ending ~= 0) then
230ending = begining + (ending * 86400)
231else
232ending = 0
233end
234
235db.executeQuery("INSERT INTO `guild_wars` (`guild_id`, `enemy_id`, `begin`, `end`, `frags`, `payment`) VALUES (" .. guild .. ", " .. enemy .. ", " .. begining .. ", " .. ending .. ", " .. frags .. ", " .. payment .. ");")
236doBroadcastMessage(getPlayerGuildName(cid) .. " has invited " .. enemyName .. " to war till " .. frags .. " frags.", MESSAGE_EVENT_ADVANCE)
237return true
238end
239
240if(not isInArray({"end", "finish"}, t[1])) then
241return false
242end
243
244local status = (t[1] == "end" and 1 or 4)
245tmp = db.getResult("SELECT `id` FROM `guild_wars` WHERE `guild_id` = " .. guild .. " AND `enemy_id` = " .. enemy .. " AND `status` = " .. status)
246if(tmp:getID() ~= -1) then
247local query = "UPDATE `guild_wars` SET `end` = " .. os.time() .. ", `status` = 5 WHERE `id` = " .. tmp:getDataInt("id")
248tmp:free()
249doGuildRemoveEnemy(guild, enemy)
250doGuildRemoveEnemy(enemy, guild)
251
252db.executeQuery(query)
253doBroadcastMessage(getPlayerGuildName(cid) .. " has " .. (status == 4 and "mend fences" or "ended up a war") .. " with " .. enemyName .. ".", MESSAGE_EVENT_ADVANCE)
254return true
255end
256
257if(status == 4) then
258doPlayerSendChannelMessage(cid, "", "Currently there's no pending war truce from " .. enemyName .. ".", TALKTYPE_CHANNEL_W, 0)
259return true
260end
261
262tmp = db.getResult("SELECT `id`, `end` FROM `guild_wars` WHERE `guild_id` = " .. enemy .. " AND `enemy_id` = " .. guild .. " AND `status` = 1")
263if(tmp:getID() ~= -1) then
264if(tmp:getDataInt("end") > 0) then
265tmp:free()
266doPlayerSendChannelMessage(cid, "", "You cannot request ending for war with " .. enemyName .. ".", TALKTYPE_CHANNEL_W, 0)
267return true
268end
269
270local query = "UPDATE `guild_wars` SET `status` = 4, `end` = " .. os.time() .. " WHERE `id` = " .. tmp:getDataInt("id")
271tmp:free()
272
273db.executeQuery(query)
274doBroadcastMessage(getPlayerGuildName(cid) .. " has signed an armstice declaration on a war with " .. enemyName .. ".", MESSAGE_EVENT_ADVANCE)
275return true
276end
277
278doPlayerSendChannelMessage(cid, "", "Currently there's no active war with " .. enemyName .. ".", TALKTYPE_CHANNEL_W, 0)
279return true
280end[/code]
281
282[b]y en talkactions.xml agregas esto:[/b]
283
284[code]
285<talkaction words="/war" channel="0" event="script" value="war.lua" desc="(Guild channel command) War management."/>
286<talkaction words="/balance" channel="0" event="script" value="balance.lua" desc="(Guild channel command) Balance management."/>[/code]
287
288
289
290MensajeTema: War System. Jue 8 Sep 2011 - 20:26 Responder citando Editar/Borrar este mensaje Borrar este mensaje Ver la dirección IP del autor Hacer un reporte del mensaje a un administrador o a un moderador Cerrar los reportes de este mensaje
291Bueno, este es el elf war system script exclusivo para los donadores de blacktibia, igual a rl, solo que se necesita el exe del tfs ya oficial para hacer funcionar los escudos y el sistema correctamente, bueno empesemos:
292
293Ve a globalevents/scripts y crea un archivo con extension de lua llamado start.lua, de ahi pon esto adentro de el:
294Código:
295
296function onStartup()
297db.executeQuery("UPDATE `players` SET `online` = 0 WHERE `world_id` = " .. getConfigValue('worldId') .. ";")
298db.executeQuery("DELETE FROM `guild_wars` WHERE `status` = 0 AND `begin` < " .. (os.time() - 2 * 86400) .. ";")
299db.executeQuery("UPDATE `guild_wars` SET `status` = 5, `end` = " .. os.time() .. " WHERE `status` = 1 AND `end` > 0 AND `end` < " .. os.time() .. ";")
300return true
301end
302
303
304y en globalevents.xml se pone esto:
305Código:
306
307<globalevent name="serverstart" type="start" event="script" value="start.lua"/>
308
309
310Despues de eso ve a el lib y ve al 000-constant, abrelo y agrega esto:
311
312Código:
313WAR_GUILD = 0
314WAR_ENEMY = 1
315
316
317Despues se va a la carpeta llamada talkactions, y creas dos archivos con extension lua, uno llamado balance y otro llamado war, y de ahi agregas lo siguiente:
318
319Balance.lua:
320Código:
321
322local function isValidMoney(value)
323if(value == nil) then
324return false
325end
326
327return (value > 0 and value <= 99999999999999)
328end
329
330function onSay(cid, words, param, channel)
331local guild = getPlayerGuildId(cid)
332if(guild == 0) then
333return false
334end
335
336local t = string.explode(param, ' ', 1)
337if(getPlayerGuildLevel(cid) == GUILDLEVEL_LEADER and isInArray({ 'pick' }, t[1])) then
338if(t[1] == 'pick') then
339local money = { tonumber(t[2]) }
340if(not isValidMoney(money[1])) then
341doPlayerSendChannelMessage(cid, '', 'Invalid amount of money specified.', TALKTYPE_CHANNEL_W, 0)
342return true
343end
344
345local result = db.getResult('SELECT `balance` FROM `guilds` WHERE `id` = ' .. guild)
346if(result:getID() == -1) then
347return false
348end
349
350money[2] = result:getDataLong('balance')
351result:free()
352
353if(money[1] > money[2]) then
354doPlayerSendChannelMessage(cid, '', 'The balance is too low for such amount.', TALKTYPE_CHANNEL_W, 0)
355return true
356end
357
358if(not db.executeQuery('UPDATE `guilds` SET `balance` = `balance` - ' .. money[1] .. ' WHERE `id` = ' .. guild .. ' LIMIT 1;')) then
359return false
360end
361
362doPlayerAddMoney(cid, money[1])
363doPlayerSendChannelMessage(cid, '', 'You have just picked ' .. money[1] .. ' money from your guild balance.', TALKTYPE_CHANNEL_W, 0)
364else
365doPlayerSendChannelMessage(cid, '', 'Invalid sub-command.', TALKTYPE_CHANNEL_W, 0)
366end
367elseif(t[1] == 'donate') then
368local money = tonumber(t[2])
369if(not isValidMoney(money)) then
370doPlayerSendChannelMessage(cid, '', 'Invalid amount of money specified.', TALKTYPE_CHANNEL_W, 0)
371return true
372end
373
374if(getPlayerMoney(cid) < money) then
375doPlayerSendChannelMessage(cid, '', 'You don\'t have enough money.', TALKTYPE_CHANNEL_W, 0)
376return true
377end
378
379if(not doPlayerRemoveMoney(cid, money)) then
380return false
381end
382
383db.executeQuery('UPDATE `guilds` SET `balance` = `balance` + ' .. money .. ' WHERE `id` = ' .. guild .. ' LIMIT 1;')
384doPlayerSendChannelMessage(cid, '', 'You have transfered ' .. money .. ' money to your guild balance.', TALKTYPE_CHANNEL_W, 0)
385else
386local result = db.getResult('SELECT `name`, `balance` FROM `guilds` WHERE `id` = ' .. guild)
387if(result:getID() == -1) then
388return false
389end
390
391doPlayerSendChannelMessage(cid, '', 'Current balance of guild ' .. result:getDataString('name') .. ' is: ' .. result:getDataLong('balance') .. ' bronze coins.', TALKTYPE_CHANNEL_W, 0)
392result:free()
393end
394
395return true
396end
397
398
399War.lua:
400
401Código:
402function onSay(cid, words, param, channel)
403local guild = getPlayerGuildId(cid)
404if(not guild or getPlayerGuildLevel(cid) < GUILDLEVEL_LEADER) then
405doPlayerSendChannelMessage(cid, "", "You cannot execute this talkaction.", TALKTYPE_CHANNEL_W, 0)
406return true
407end
408
409local t = string.explode(param, ",")
410if(not t[2]) then
411doPlayerSendChannelMessage(cid, "", "Not enough param(s).", TALKTYPE_CHANNEL_W, 0)
412return true
413end
414
415local enemy = getGuildId(t[2])
416if(not enemy) then
417doPlayerSendChannelMessage(cid, "", "Guild \"" .. t[2] .. "\" does not exists.", TALKTYPE_CHANNEL_W, 0)
418return true
419end
420
421if(enemy == guild) then
422doPlayerSendChannelMessage(cid, "", "You cannot perform war action on your own guild.", TALKTYPE_CHANNEL_W, 0)
423return true
424end
425
426local enemyName, tmp = "", db.getResult("SELECT `name` FROM `guilds` WHERE `id` = " .. enemy)
427if(tmp:getID() ~= -1) then
428enemyName = tmp:getDataString("name")
429tmp:free()
430end
431
432if(isInArray({"accept", "reject", "cancel"}, t[1])) then
433local query = "`guild_id` = " .. enemy .. " AND `enemy_id` = " .. guild
434if(t[1] == "cancel") then
435query = "`guild_id` = " .. guild .. " AND `enemy_id` = " .. enemy
436end
437
438tmp = db.getResult("SELECT `id`, `begin`, `end`, `payment` FROM `guild_wars` WHERE " .. query .. " AND `status` = 0")
439if(tmp:getID() == -1) then
440doPlayerSendChannelMessage(cid, "", "Currently there's no pending invitation for a war with " .. enemyName .. ".", TALKTYPE_CHANNEL_W, 0)
441return true
442end
443
444if(t[1] == "accept") then
445local _tmp = db.getResult("SELECT `balance` FROM `guilds` WHERE `id` = " .. guild)
446local state = _tmp:getID() < 0 or _tmp:getDataInt("balance") < tmp:getDataInt("payment")
447
448_tmp:free()
449if(state) then
450doPlayerSendChannelMessage(cid, "", "Your guild balance is too low to accept this invitation.", TALKTYPE_CHANNEL_W, 0)
451return true
452end
453
454db.executeQuery("UPDATE `guilds` SET `balance` = `balance` - " .. tmp:getDataInt("payment") .. " WHERE `id` = " .. guild)
455end
456
457query = "UPDATE `guild_wars` SET "
458local msg = "accepted " .. enemyName .. " invitation to war."
459if(t[1] == "reject") then
460query = query .. "`end` = " .. os.time() .. ", `status` = 2"
461msg = "rejected " .. enemyName .. " invitation to war."
462elseif(t[1] == "cancel") then
463query = query .. "`end` = " .. os.time() .. ", `status` = 3"
464msg = "canceled invitation to a war with " .. enemyName .. "."
465else
466query = query .. "`begin` = " .. os.time() .. ", `end` = " .. (tmp:getDataInt("end") > 0 and (os.time() + ((tmp:getDataInt("begin") - tmp:getDataInt("end")) / 86400)) or 0) .. ", `status` = 1"
467end
468
469query = query .. " WHERE `id` = " .. tmp:getDataInt("id")
470if(t[1] == "accept") then
471doGuildAddEnemy(guild, enemy, tmp:getDataInt("id"), WAR_GUILD)
472doGuildAddEnemy(enemy, guild, tmp:getDataInt("id"), WAR_ENEMY)
473end
474
475tmp:free()
476db.executeQuery(query)
477doBroadcastMessage(getPlayerGuildName(cid) .. " has " .. msg, MESSAGE_EVENT_ADVANCE)
478return true
479end
480
481if(t[1] == "invite") then
482local str = ""
483tmp = db.getResult("SELECT `guild_id`, `status` FROM `guild_wars` WHERE `guild_id` IN (" .. guild .. "," .. enemy .. ") AND `enemy_id` IN (" .. enemy .. "," .. guild .. ") AND `status` IN (0, 1)")
484if(tmp:getID() ~= -1) then
485if(tmp:getDataInt("status") == 0) then
486if(tmp:getDataInt("guild_id") == guild) then
487str = "You have already invited " .. enemyName .. " to war."
488else
489str = enemyName .. " have already invited you to war."
490end
491else
492str = "You are already on a war with " .. enemyName .. "."
493end
494
495tmp:free()
496end
497
498if(str ~= "") then
499doPlayerSendChannelMessage(cid, "", str, TALKTYPE_CHANNEL_W, 0)
500return true
501end
502
503local frags = tonumber(t[3])
504if(frags ~= nil) then
505frags = math.max(10, math.min(1000, frags))
506else
507frags = 100
508end
509
510local payment = tonumber(t[4])
511if(payment ~= nil) then
512payment = math.max(100000, math.min(1000000000, payment))
513tmp = db.getResult("SELECT `balance` FROM `guilds` WHERE `id` = " .. guild)
514
515local state = tmp:getID() < 0 or tmp:getDataInt("balance") < payment
516tmp:free()
517if(state) then
518doPlayerSendChannelMessage(cid, "", "Your guild balance is too low for such payment.", TALKTYPE_CHANNEL_W, 0)
519return true
520end
521
522db.executeQuery("UPDATE `guilds` SET `balance` = `balance` - " .. payment .. " WHERE `id` = " .. guild)
523else
524payment = 0
525end
526
527local begining, ending = os.time(), tonumber(t[5])
528if(ending ~= nil and ending ~= 0) then
529ending = begining + (ending * 86400)
530else
531ending = 0
532end
533
534db.executeQuery("INSERT INTO `guild_wars` (`guild_id`, `enemy_id`, `begin`, `end`, `frags`, `payment`) VALUES (" .. guild .. ", " .. enemy .. ", " .. begining .. ", " .. ending .. ", " .. frags .. ", " .. payment .. ");")
535doBroadcastMessage(getPlayerGuildName(cid) .. " has invited " .. enemyName .. " to war till " .. frags .. " frags.", MESSAGE_EVENT_ADVANCE)
536return true
537end
538
539if(not isInArray({"end", "finish"}, t[1])) then
540return false
541end
542
543local status = (t[1] == "end" and 1 or 4)
544tmp = db.getResult("SELECT `id` FROM `guild_wars` WHERE `guild_id` = " .. guild .. " AND `enemy_id` = " .. enemy .. " AND `status` = " .. status)
545if(tmp:getID() ~= -1) then
546local query = "UPDATE `guild_wars` SET `end` = " .. os.time() .. ", `status` = 5 WHERE `id` = " .. tmp:getDataInt("id")
547tmp:free()
548doGuildRemoveEnemy(guild, enemy)
549doGuildRemoveEnemy(enemy, guild)
550
551db.executeQuery(query)
552doBroadcastMessage(getPlayerGuildName(cid) .. " has " .. (status == 4 and "mend fences" or "ended up a war") .. " with " .. enemyName .. ".", MESSAGE_EVENT_ADVANCE)
553return true
554end
555
556if(status == 4) then
557doPlayerSendChannelMessage(cid, "", "Currently there's no pending war truce from " .. enemyName .. ".", TALKTYPE_CHANNEL_W, 0)
558return true
559end
560
561tmp = db.getResult("SELECT `id`, `end` FROM `guild_wars` WHERE `guild_id` = " .. enemy .. " AND `enemy_id` = " .. guild .. " AND `status` = 1")
562if(tmp:getID() ~= -1) then
563if(tmp:getDataInt("end") > 0) then
564tmp:free()
565doPlayerSendChannelMessage(cid, "", "You cannot request ending for war with " .. enemyName .. ".", TALKTYPE_CHANNEL_W, 0)
566return true
567end
568
569local query = "UPDATE `guild_wars` SET `status` = 4, `end` = " .. os.time() .. " WHERE `id` = " .. tmp:getDataInt("id")
570tmp:free()
571
572db.executeQuery(query)
573doBroadcastMessage(getPlayerGuildName(cid) .. " has signed an armstice declaration on a war with " .. enemyName .. ".", MESSAGE_EVENT_ADVANCE)
574return true
575end
576
577doPlayerSendChannelMessage(cid, "", "Currently there's no active war with " .. enemyName .. ".", TALKTYPE_CHANNEL_W, 0)
578return true
579end
580
581
582y en talkactions.xml agregas esto:
583
584Código:
585<talkaction words="/war" channel="0" event="script" value="war.lua" desc="(Guild channel command) War management."/>
586<talkaction words="/balance" channel="0" event="script" value="balance.lua" desc="(Guild channel command) Balance management."/>
587
588
589
590[b]y ya solamente faltaria agregar la columna de war en la database, entras y ejecutas el sql, ahi dentro pones esto:[/b]
591
592[code]
593CREATE TABLE IF NOT EXISTS `guild_wars` (
594`id` INT NOT NULL AUTO_INCREMENT,
595`guild_id` INT NOT NULL,
596`enemy_id` INT NOT NULL,
597`begin` BIGINT NOT NULL DEFAULT '0',
598`end` BIGINT NOT NULL DEFAULT '0',
599`frags` INT UNSIGNED NOT NULL DEFAULT '0',
600`payment` BIGINT UNSIGNED NOT NULL DEFAULT '0',
601`guild_kills` INT UNSIGNED NOT NULL DEFAULT '0',
602`enemy_kills` INT UNSIGNED NOT NULL DEFAULT '0',
603`status` TINYINT(1) UNSIGNED NOT NULL DEFAULT '0',
604PRIMARY KEY (`id`),
605KEY `status` (`status`),
606KEY `guild_id` (`guild_id`),
607KEY `enemy_id` (`enemy_id`)
608) ENGINE=InnoDB;
609
610ALTER TABLE `guild_wars`
611ADD CONSTRAINT `guild_wars_ibfk_1` FOREIGN KEY (`guild_id`) REFERENCES `guilds` (`id`) ON DELETE CASCADE,
612ADD CONSTRAINT `guild_wars_ibfk_2` FOREIGN KEY (`enemy_id`) REFERENCES `guilds` (`id`) ON DELETE CASCADE;
613
614ALTER TABLE `guilds` ADD `balance` BIGINT UNSIGNED NOT NULL AFTER `motd`;
615
616CREATE TABLE IF NOT EXISTS `guild_kills` (
617`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
618`guild_id` INT NOT NULL,
619`war_id` INT NOT NULL,
620`death_id` INT NOT NULL
621) ENGINE = InnoDB;
622
623ALTER TABLE `guild_kills`
624ADD CONSTRAINT `guild_kills_ibfk_1` FOREIGN KEY (`war_id`) REFERENCES `guild_wars` (`id`) ON DELETE CASCADE,
625ADD CONSTRAINT `guild_kills_ibfk_2` FOREIGN KEY (`death_id`) REFERENCES `player_deaths` (`id`) ON DELETE CASCADE,
626ADD CONSTRAINT `guild_kills_ibfk_3` FOREIGN KEY (`guild_id`) REFERENCES `guilds` (`id`) ON DELETE CASCADE;
627
628ALTER TABLE `killers` ADD `war` INT NOT NULL DEFAULT 0;[/code]