Jump to content
  • 0
Sign in to follow this  
ZelosAvalon

Event Ranking

Question

 

OnMyMobDead: //When a Monster is killed
    set .mobs_left, .mobs_left-1;
    if (.mobs_left==0) {
        announce "[ Rune-Midgard Guard ]: "+getmonsterinfo(.MvpID,0)+" has spawned in " + .Map$ + "!", bc_all;
        monster .Map$,0,0,getmonsterinfo(.MvpID,0),.MvpID,1,"Event Invasion::OnSpecialMobDead";
 
    } else {
        query_sql "INSERT INTO event_rank (id, name, event_points) values('"+getcharid(0)+"','"+strcharinfo(0)+"','1') ON DUPLICATE KEY UPDATE event_points = event_points + '1'";
        query_sql "INSERT INTO event_rank (id, name, t_event_points) values('"+getcharid(0)+"','"+strcharinfo(0)+"','1') ON DUPLICATE KEY UPDATE t_event_points = t_event_points + '1'";
        announce "["+.mobs_left+"/"+.MobX+"] Monster left.",bc_map;
    }
    end;

 

i have two parameters, one i should use a temporary the "event_point" and an permanent "t_event_points" permanent. When killing a mob I would like that added the sql table in both, however I do not have much sql knowledge, I tried one way and gave error, someone could me help? when i finish my event i'll share it! ^^

 

"when i kill a mob event_point add+1 and t_event_point add +1"

 

I receive this error:

 

[Debug]: Source (NPC): Event Invasion at prontera (148,178)
: DB error - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''event_points','t_event_points' = event_points + '1', t_event_points + '1'' at line 1
 
my sql table:

 

DROP TABLE IF EXISTS `event_rank`;
CREATE TABLE `event_rank` (
  `id` smallint(5) UNSIGNED NOT NULL DEFAULT '0',
  `name` varchar(50) NOT NULL DEFAULT '',
  `event_points` mediumint(50) DEFAULT NULL,
  `t_event_points` mediumint(50) DEFAULT NULL,
 PRIMARY KEY (`id`)
) ENGINE=MyISAM;

 

Edited by ZelosAvalon

Share this post


Link to post
Share on other sites

7 answers to this question

Recommended Posts

  • 0

Use this SQL Table:

 

 

 

CREATE TABLE IF NOT EXISTS `event_rank` (
  `id` INT(11) UNSIGNED NOT NULL DEFAULT '0',
  `name` VARCHAR(30) NOT NULL DEFAULT '',
  `event_points` INT(11) UNSIGNED NOT NULL DEFAULT '0',
  `t_event_points` INT(11) UNSIGNED NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`)
) ENGINE=MyISAM;

 

 

 

Now try it:

 

query_sql "INSERT INTO `event_rank`(`id`, `name`, `event_points`, `t_event_points`) VALUES ('"+getcharid(3)+"','"+strcharinfo(0)+"','1','1') ON DUPLICATE KEY UPDATE `event_points` = `event_points` + '1', `t_event_points` = `t_event_points` + '1'";

 

Tested and works.

Share this post


Link to post
Share on other sites
  • 0

 

Use this SQL Table:

 

 

 

CREATE TABLE IF NOT EXISTS `event_rank` (
  `id` INT(11) UNSIGNED NOT NULL DEFAULT '0',
  `name` VARCHAR(30) NOT NULL DEFAULT '',
  `event_points` INT(11) UNSIGNED NOT NULL DEFAULT '0',
  `t_event_points` INT(11) UNSIGNED NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`)
) ENGINE=MyISAM;

 

 

 

Now try it:

 

query_sql "INSERT INTO `event_rank`(`id`, `name`, `event_points`, `t_event_points`) VALUES ('"+getcharid(3)+"','"+strcharinfo(0)+"','1','1') ON DUPLICATE KEY UPDATE `event_points` = `event_points` + '1', `t_event_points` = `t_event_points` + '1'";

 

Tested and works.

 

Use this SQL Table:

 

 

 

CREATE TABLE IF NOT EXISTS `event_rank` (
  `id` INT(11) UNSIGNED NOT NULL DEFAULT '0',
  `name` VARCHAR(30) NOT NULL DEFAULT '',
  `event_points` INT(11) UNSIGNED NOT NULL DEFAULT '0',
  `t_event_points` INT(11) UNSIGNED NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`)
) ENGINE=MyISAM;

 

 

 

Now try it:

 

query_sql "INSERT INTO `event_rank`(`id`, `name`, `event_points`, `t_event_points`) VALUES ('"+getcharid(3)+"','"+strcharinfo(0)+"','1','1') ON DUPLICATE KEY UPDATE `event_points` = `event_points` + '1', `t_event_points` = `t_event_points` + '1'";

 

Tested and works.

thank you vm :thx:  working now!!

 

can you give me a hand with this part too ?

 

my formula to convert event points in "event coins: ID8052 in my case" I tried to change some things, but it didn't work.

 

20 event_points = 1 event coin

for example: if i input 27 event_points npc will give me 1 event coin and return 7 event points.

 

 

OLD FORMULA when event_points was the var: #Event_point

switch(select("Convert Event Points:Back")) {
		case 1:
				{if(#Event_point < 20) 
				goto noEP;
				}
				{ if(#Event_point >= 20)
				.@remainDiv = #Event_point%20;
				.@remaindiv01 = #Event_point - .@remainDiv;
				set #Event_point, #Event_point - .@remaindiv01;
				mes " [Event Manager]";
				mes "Thank you for choosing ^777777RagnaRebirth^000000 that luck be with you in future events, and you can win many Coins.";
				.@remaindiv01 = .@remaindiv01/20;
				getitem 8052,.@remaindiv01;
				close;
				}
		case 2:
		goto Main;
	}

 

NEW FORMULA (I tried, but failed! )  :omg:

 

 
switch(select("Convert Event Points:Back")) {
		case 1:
		query_sql "SELECT `event_points` FROM `event_rank` ORDER BY `event_points` DESC LIMIT "+$topevent+"",@event_points$;
				{if(@event_points$ < 20) 
				goto noEP;
				}
				{ if(@event_points$ >= 20)
				.@remainDiv = @event_points$%20;
				.@remaindiv01 = @event_points$ - .@remainDiv;
				set @event_points$, @event_points$ - .@remaindiv01;
				query_sql "INSERT INTO `event_rank`(`id`, `name`, `event_points`) VALUES ('"+getcharid(3)+"','"+strcharinfo(0)+"','1') ON DUPLICATE KEY UPDATE `event_points` = `event_points` - '@event_points$'";
				mes " [Event Manager]";
				mes "Thank you for choosing ^777777myRO^000000 that luck be with you in future events, and you can win many Coins.";
				.@remaindiv01 = .@remaindiv01/20;
				getitem 8052,.@remaindiv01;
				close;
				}
		case 2:
		goto Main;
	}

in this part: 

 

query_sql "SELECT `event_points` FROM `event_rank` ORDER BY `event_points` DESC LIMIT "+$topevent+"",@event_points$;

how can i remove "+$topevent+" when I removed gave me an error!

Edited by ZelosAvalon

Share this post


Link to post
Share on other sites
  • 0

Try this, It works here. :)


 

prontera,155,168,5    script    Testing#1    4W_F_KAFRA2,{
    .@item_id = 502;
    .@item_cost = 20;
 
    query_sql "SELECT `event_points` FROM `event_rank` WHERE `id` = '"+getcharid(3)+"'", .@points;
 
    if (.@item_cost > .@points)
    {
        // We don't have what we need.
        mes "Sorry, but you don't have " + .@item_cost + " Event Points.";
        close;
    }
    else
    {
        .@result = .@points / .@item_cost;
        .@rest = .@points % .@item_cost;
        mes "You can get "+.@result+"x " + getitemname(.@item_id) + " and you will have " + .@rest + " Event Points";
        mes "You want trade?";
    
        if (select("Yes:No") == 2)
            close;
    
        getitem .@item_id, .@result;
        query_sql "UPDATE `event_rank` SET `event_points` = '"+.@rest+"' WHERE `id` = '"+getcharid(3)+"'";
        mes "Here it is";
        close;
    }
}

 



Note: You will need change 'getcharid(3)' to 'getcharid(0)' if you want save character number id, because 'getcharid(3)' save account number id.

Edited by Cretino

Share this post


Link to post
Share on other sites
  • 0

Try this, It works here. :)

 

 

 

prontera,155,168,5    script    Testing#1    4W_F_KAFRA2,{
    .@item_id = 502;
    .@item_cost = 20;
 
    query_sql "SELECT `event_points` FROM `event_rank` WHERE `id` = '"+getcharid(3)+"'", .@points;
 
    if (.@item_cost > .@points)
    {
        // We don't have what we need.
        mes "Sorry, but you don't have " + .@item_cost + " Event Points.";
        close;
    }
    else
    {
        .@result = .@points / .@item_cost;
        .@rest = .@points % .@item_cost;
        mes "You can get "+.@result+"x " + getitemname(.@item_id) + " and you will have " + .@rest + " Event Points";
        mes "You want trade?";
    
        if (select("Yes:No") == 2)
            close;
    
        getitem .@item_id, .@result;
        query_sql "UPDATE `event_rank` SET `event_points` = '"+.@rest+"' WHERE `id` = '"+getcharid(3)+"'";
        mes "Here it is";
        close;
    }
}

 

 

 

Note: You will need change 'getcharid(3)' to 'getcharid(0)' if you want save character number id, because 'getcharid(3)' save account number id.

ty :thx:  you are amazing! working now ^^

Edited by ZelosAvalon

Share this post


Link to post
Share on other sites
  • 0

Try this, It works here. :)

 

 

 

prontera,155,168,5    script    Testing#1    4W_F_KAFRA2,{
    .@item_id = 502;
    .@item_cost = 20;
 
    query_sql "SELECT `event_points` FROM `event_rank` WHERE `id` = '"+getcharid(3)+"'", .@points;
 
    if (.@item_cost > .@points)
    {
        // We don't have what we need.
        mes "Sorry, but you don't have " + .@item_cost + " Event Points.";
        close;
    }
    else
    {
        .@result = .@points / .@item_cost;
        .@rest = .@points % .@item_cost;
        mes "You can get "+.@result+"x " + getitemname(.@item_id) + " and you will have " + .@rest + " Event Points";
        mes "You want trade?";
    
        if (select("Yes:No") == 2)
            close;
    
        getitem .@item_id, .@result;
        query_sql "UPDATE `event_rank` SET `event_points` = '"+.@rest+"' WHERE `id` = '"+getcharid(3)+"'";
        mes "Here it is";
        close;
    }
}

 

 

 

Note: You will need change 'getcharid(3)' to 'getcharid(0)' if you want save character number id, because 'getcharid(3)' save account number id.

 

Here's my Invasion Event,  if you want to check, and if you have any tips to how to improve it! Invasion_Event_v1.5

I know I can decrease the code, especially in parts of the cities, but I was a long time without messing with ragnarok scripts and now i have to remember a lot of things, but it's functional !

PS: i try, but i dont know how to implement an option on the menu to choose the day and time to start the event, you showed me an example I tried to follow him, but there were several errors.

Edited by ZelosAvalon

Share this post


Link to post
Share on other sites
  • 0

I will look your script and try to mount the part to start the event for you to understand a bit how it works, it's a little complicated at first, I had much difficulty, but it is now quite simple.
 
@EDIT

 

@@ZelosAvalon

Here is the script, I rewrite all script.
You can see and make your event now.
 
Edited by Cretino

Share this post


Link to post
Share on other sites
  • 0

 

I will look your script and try to mount the part to start the event for you to understand a bit how it works, it's a little complicated at first, I had much difficulty, but it is now quite simple.

 

@EDIT

 

@@ZelosAvalon

Here is the script, I rewrite all script.
You can see and make your event now.
 

Great job =) i'll working for try to inprove it too!  :thx:

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.