Poring King Posted October 14, 2020 Group: Members Topic Count: 63 Topics Per Day: 0.02 Content Count: 1016 Reputation: 191 Joined: 11/27/14 Last Seen: February 15 Share Posted October 14, 2020 Hello im trying to add automatically a column in my database if not exist thru NPC Script . ALTER TABLE IF NOT EXIST `guild` ( ADD `woe_point` INT(11) UNSIGNED NOT NULL DEFAULT '0', ) ENGINE = MYISAM; Quote Link to comment Share on other sites More sharing options...
0 AnnieRuru Posted October 14, 2020 Group: Members Topic Count: 18 Topics Per Day: 0.00 Content Count: 2044 Reputation: 682 Joined: 10/09/12 Last Seen: December 20, 2020 Share Posted October 14, 2020 I don't recommend alter a column from official table Spoiler just write for fun, but please don't do it - script kjhksjhf FAKE_NPC,{ OnInit: if (!query_sql("SHOW COLUMNS FROM `guild` WHERE `Field` = 'woe_points'", .@fields, .@a, .@b, .@c, .@d, .@e)) query_sql "ALTER TABLE `guild` ADD COLUMN `woe_points` INT DEFAULT 0 AFTER `skill_point`, ADD INDEX(`woe_points`)"; end; } honestly just create a new table CREATE TABLE `guild_woe_points` ( `guild_id` INT PRIMARY KEY, `guild_name` VARCHAR(23), `woe_points` INT, KEY(`woe_points`) ) ENGINE = InnoDB; then just query_sql "INSERT INTO `guild_woe_points` VALUES ("+ getcharid(2) +", '"+ escape_sql(strcharinfo(2)) +"', 1) ON DUPLICATE KEY UPDATE `woe_points` = `woe_points` +1; Quote Link to comment Share on other sites More sharing options...
0 Poring King Posted October 14, 2020 Group: Members Topic Count: 63 Topics Per Day: 0.02 Content Count: 1016 Reputation: 191 Joined: 11/27/14 Last Seen: February 15 Author Share Posted October 14, 2020 (edited) @AnnieRuru Well to be honest im trying to update and upgrade your old script prontera,155,181,5 script Woe Points 100,{ .@nb = query_sql( "select name, woe_points from guild order by woe_points desc limit 3", .@guild_name$, .@points ); for ( .@i = 0; .@i < .@nb; .@i++ ) { if ( !.@points[.@i] ) break; mes ( .@i +1 )+". "+ .@guild_name$[.@i] +" -> "+ .@points[.@i]; } close; OnClock1930: OnClock2000: OnClock2030: OnClock2100: for ( .@i = 0; .@i < 30; .@i++ ) { .@castle_guild_id = getcastledata( getvariableofnpc( .Castles$[.@i], "WOE_CONTROL" ), 1 ); if ( getvariableofnpc( .Active[0], "WOE_CONTROL" ) & 1 << .@i && .@castle_guild_id ) query_sql "update guild set woe_points = woe_points +1 where guild_id = "+ .@castle_guild_id; } end; OnBreakEmp: // put doevent under OnAgitBreak ... query_sql "update guild set woe_points = woe_points +1 where guild_id = "+ getcharid(2); end; } Im planning to Add Shop(That only Guild Master can Access) , Get the points and use it for the fake_npc shop Automatically Install if the column is not exist (SQL) Get the last guild from the recently woe winners and give +(MorePoints) Edited October 14, 2020 by Poring King Quote Link to comment Share on other sites More sharing options...
0 AnnieRuru Posted October 14, 2020 Group: Members Topic Count: 18 Topics Per Day: 0.00 Content Count: 2044 Reputation: 682 Joined: 10/09/12 Last Seen: December 20, 2020 Share Posted October 14, 2020 if you mean my old script from 2013, yeah I have learned things since then in fact anything I made before 2015 should be scrap I've seen your script collection release topic, you should be able to handle this kind of modification .... this is script support section after all ... no spoon feed and ? which part you don't understand ? 5 hours ago, Poring King said: Get the last guild from the recently woe winners and give +(MorePoints) just add the ON DUPLICATE KEY UPDATE statement inside OnAgitBreak label of woe script 1 Quote Link to comment Share on other sites More sharing options...
0 Poring King Posted October 14, 2020 Group: Members Topic Count: 63 Topics Per Day: 0.02 Content Count: 1016 Reputation: 191 Joined: 11/27/14 Last Seen: February 15 Author Share Posted October 14, 2020 16 minutes ago, AnnieRuru said: if you mean my old script from 2013, yeah I have learned things since then in fact anything I made before 2015 should be scrap I've seen your script collection release topic, you should be able to handle this kind of modification .... this is script support section after all ... no spoon feed and ? which part you don't understand ? just add the ON DUPLICATE KEY UPDATE statement inside OnAgitBreak label of woe script Still learning ^_^ . Ok Thx for your effort Quote Link to comment Share on other sites More sharing options...
Question
Poring King
Hello im trying to add automatically a column in my database if not exist thru NPC Script .
ALTER TABLE IF NOT EXIST `guild` ( ADD `woe_point` INT(11) UNSIGNED NOT NULL DEFAULT '0', ) ENGINE = MYISAM;
Link to comment
Share on other sites
4 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.