This is essentially just a small modification to the itemizer release that's been floating around for the last few years, and I'm running across a weird problem that I can't seem to fix.
Script:
- script item -1,{
OnWhisperGlobal:
if (getgmlevel() >= 40) {
rewardOption:
mes "[^3333FFAthena^000000]";
mes "More free items? What is it this time?";
menu "Player Reward",PlayerReward,"Event Consolation",Consolation,"Nevermind",nvm;
nvm:
next;
mes "[^3333FFAthena^000000]";
mes "Good! Stop spoonfeeding these kids!";
close;
PlayerReward:
next;
mes "[^3333FFAthena^000000]";
mes "Input the player's name EXACTLY as it is spelled.";
set @charAccNumber,getcharid(3,strcharinfo(0));
set @when$,callfunc("makeTimestamp");
set @N_Itemname$,escape_sql(getitemname(@itemID));
input @playerName$;
next;
mes "[^3333FFAthena^000000]";
mes "Set the Item ID for this reward.";
input @itemID,501,32767;
next;
mes "[^3333FFAthena^000000]";
mes "How many "+getitemname(@itemID)+"s will you give?";
input @Amount,0,30000;
next;
mes "[^3333FFAthena^000000]";
mes "Please leave a brief reason for this reward.";
mes "example: Winner of Zombie Event";
input @reason$;
next;
mes "[^3333FFAthena^000000]";
mes "Player Name : "+@playerName$+" ";
mes "Reward : "+getitemname(@itemID)+" ";
mes "Amount : "+@Amount+" ";
mes " ";
mes "Reason:";
mes ""+@reason$+"";
mes " ";
mes "^F00000Please make sure this player is ONLINE.^000000";
next;
switch(select("Change Reward","Confirm Reward","Cancel")) {
case 1:
goto PlayerReward;
case 2:
mes "The item has been given to the selected player.";
getitem @itemID,@Amount,getcharid(3,@playerName$);
announce "The Event Manager "+strcharinfo(0)+" has rewarded "+@playerName$+" with "+@Amount+" "+getitemname(@itemID)+".",bc_all;
set @itemID,query_sql("INSERT INTO `item_reward` VALUES(NULL,'"+ @charAccNumber +"','"+ strcharinfo(0) +"','"+ @itemID +"','"+ @Amount +"','"+ @N_Itemname$ +"','"+ @playerName$ +"','"+ @reason$ +"','"+ @when$ +"')");
close;
case 3:
close;
}
}
else {
dispbottom "Sorry, but you do not have permission to access this feature.";
}
Consolation:
next;
mes "[^3333FFAthena^000000]";
mes "Set the Item ID for this consolation.";
set @CcharAccNumber,getcharid(3,strcharinfo(0));
set @Cwhen$,callfunc("makeTimestamp");
set @CN_Itemname$,escape_sql(getitemname(@CitemID));
input @CitemID,501,32767;
next;
mes "[^3333FFAthena^000000]";
mes "How many "+getitemname(@CitemID)+"s will you drop?";
input @CAmount,0,30000;
next;
mes "[^3333FFAthena^000000]";
mes "Please leave a brief reason for this consolation.";
mes "example: Consolation for Zombie Event";
input @Creason$;
next;
mes "[^3333FFAthena^000000]";
mes "Consolation : "+getitemname(@CitemID)+" ";
mes "Amount : "+@CAmount+" ";
mes " ";
mes "Reason:";
mes ""+@Creason$+"";
next;
switch(select("Change Consolation","Confirm Consolation","Cancel")) {
case 1:
goto Consolation;
case 2:
mes "The item has been given to the selected player.";
atcommand "@flooritem "+@CitemID+" "+@CAmount+"";
set @itemID,query_sql("INSERT INTO `item_reward` VALUES(NULL,'"+ @CcharAccNumber +"','"+ strcharinfo(0) +"','"+ @CitemID +"','"+ @CAmount +"','"+ @CN_Itemname$ +"','"+ @Creason$ +"','"+ @Cwhen$ +"')");
close;
case 3:
goto nvm;
}
}
else {
dispbottom "Sorry, but you do not have permission to access this feature.";
}
}
function script makeTimestamp {
// Get Current Date & Time Variables
set @curYear,gettime(7);
set @curMonth,gettime(6);
set @curDay,gettime(5);
set @curHour,gettime(3);
set @curMinute,gettime(2);
set @curSecond,gettime(1);
// Start A New Timestamp Variable
set @timestamp$,"";
// MySQL Timestamp Friendly :: Year
set @timestamp$,@timestamp$+@curYear+"-";
// MySQL Timestamp Friendly :: Month
if (@curMonth <= 9) {
set @timestamp$,@timestamp$+"0"+@curMonth+"-";
}
else {
set @timestamp$,@timestamp$+@curMonth+"-";
}
// MySQL Timestamp Friendly :: Day
if (@curDay <= 9) {
set @timestamp$,@timestamp$+"0"+@curDay+" ";
}
else {
set @timestamp$,@timestamp$+@curDay+" ";
}
// MySQL Timestamp Friendly :: Hour
if (@curHour <= 9) {
set @timestamp$,@timestamp$+"0"+@curHour+":";
}
else {
set @timestamp$,@timestamp$+@curHour+":";
}
// MySQL Timestamp Friendly :: Minute
if (@curMinute <= 9) {
set @timestamp$,@timestamp$+"0"+@curMinute+":";
}
else {
set @timestamp$,@timestamp$+@curMinute+":";
}
// MySQL Timestamp Friendly :: Second
if (@curSecond <= 9) {
set @timestamp$,@timestamp$+"0"+@curSecond;
}
else {
set @timestamp$,@timestamp$+@curSecond;
}
// Return MySQL Friendly Timestamp
return @timestamp$;
}
I modified it so GMs can access it via whisper, must give a reason, and restructured the log's table in my database for easy reading. In that regard, the NPC works great and does what it's supposed to.
What I recently did was add a menu in the beginning, which would distinguish player prizes from @flooritem consolations. For the Consolation section, I basically duplicated the script and tweaked it a bit to correspond with the log table I made for it. Right now, it freezes completely when I get to this part in either switch:
set @charAccNumber,getcharid(3,strcharinfo(0));
set @when$,callfunc("makeTimestamp");
set @N_Itemname$,escape_sql(getitemname(@itemID));
set @CcharAccNumber,getcharid(3,strcharinfo(0));
set @Cwhen$,callfunc("makeTimestamp");
set @CN_Itemname$,escape_sql(getitemname(@CitemID));
When I was debugging, I learned that it was likely the callfunc that was screwing things up. I thought maybe the server simply didn't like that there were two callfunc's in the same script, but what do I know - I'm here, aren't I? I tried making a copy of makeTimestamp and naming it makeTimestamp2 (and further defining it in Consolation's callfunc), but that did absolutely nothing.
If anyone has an answer and would like to share it with me, it'd be really helpful and greatly appreciated. Thanks for reading.
Edit: Nevermind, I found the problem myself. There were several errors that didn't show up on my console, and just some poor code structure. I know none of you who initially read this replied, but I'd like to share the final product anyways to help combat GM corruption. This final script works and functions fully as intended.
// --------------------------------------------------------------
// Original Script by latheesan
// Modifications by Glitch - Deliverance-Online
// Item reward system for GMs; logged to MySQL database.
// @flooritem feature for consolation purposes; logged.
// - Run this query! --------------------------------------------
//CREATE TABLE IF NOT EXISTS `item_reward` (
// `id` int(11) unsigned NOT NULL auto_increment,
// `account` int(11) NOT NULL,
// `name` varchar(255) NOT NULL,
// `item_id` int(11) NOT NULL,
// `item_amount` int(11) NOT NULL,
// `item_name` varchar(255) NOT NULL,
// `for` varchar(255) NOT NULL,
// `reason` varchar(255) NOT NULL,
// `when` datetime NOT NULL,
// PRIMARY KEY (`id`)
//) ENGINE=MyISAM;
// - And this one: -----------------------------------------------
//CREATE TABLE IF NOT EXISTS `item_consolation` (
// `id` int(11) unsigned NOT NULL auto_increment,
// `account` int(11) NOT NULL,
// `name` varchar(255) NOT NULL,
// `item_id` int(11) NOT NULL,
// `item_amount` int(11) NOT NULL,
// `item_name` varchar(255) NOT NULL,
// `reason` varchar(255) NOT NULL,
// `when` datetime NOT NULL,
// PRIMARY KEY (`id`)
//) ENGINE=MyISAM;
// --------------------------------------------------------------
- script item -1,{
OnWhisperGlobal:
if (getgmlevel() >= 40) {
// set @when$,callfunc("makeTimestamp");
rewardOption:
mes "[^3333FFAthena^000000]";
mes "More free items? What is it this time?";
menu "Player Reward",PlayerReward,"Event Consolation",Consolation,"Nevermind",nvm;
nvm:
next;
mes "[^3333FFAthena^000000]";
mes "Good! Stop spoonfeeding these kids!";
close;
PlayerReward:
next;
mes "[^3333FFAthena^000000]";
mes "Input the player's name EXACTLY as it is spelled.";
input @playerName$;
set @charAccNumber,getcharid(3,strcharinfo(0));
set @when$,callfunc("makeTimestamp");
set @N_Itemname$,escape_sql(getitemname(@itemID));
next;
mes "[^3333FFAthena^000000]";
mes "Set the Item ID for this reward.";
input @itemID,501,32767;
next;
mes "[^3333FFAthena^000000]";
mes "How many "+getitemname(@itemID)+"s will you give?";
input @Amount,0,30000;
next;
mes "[^3333FFAthena^000000]";
mes "Please leave a brief reason for this reward.";
mes "example: Winner of Zombie Event";
input @reason$;
next;
mes "[^3333FFAthena^000000]";
mes "Player Name : "+@playerName$+" ";
mes "Reward : "+getitemname(@itemID)+" ";
mes "Amount : "+@Amount+" ";
mes " ";
mes "Reason:";
mes ""+@reason$+"";
mes " ";
mes "^F00000Please make sure this player is ONLINE.^000000";
next;
switch(select("Change Reward","Confirm Reward","Cancel")) {
case 1:
goto PlayerReward;
case 2:
mes "The item has been given to the selected player.";
getitem @itemID,@Amount,getcharid(3,@playerName$);
announce "The Event Manager "+strcharinfo(0)+" has rewarded "+@playerName$+" with "+@Amount+" "+getitemname(@itemID)+".",bc_all;
set @itemID,query_sql("INSERT INTO `item_reward` VALUES(NULL,'"+ @charAccNumber +"','"+ strcharinfo(0) +"','"+ @itemID +"','"+ @Amount +"','"+ @N_Itemname$ +"','"+ @playerName$ +"','"+ @reason$ +"','"+ @when$ +"')");
close;
case 3:
close;
}
Consolation:
next;
mes "[^3333FFAthena^000000]";
mes "Set the Item ID for this consolation.";
input @itemID,501,32767;
set @charAccNumber,getcharid(3,strcharinfo(0));
set @when$,callfunc("makeTimestamp");
set @N_Itemname$,escape_sql(getitemname(@itemID));
next;
mes "[^3333FFAthena^000000]";
mes "How many "+getitemname(@itemID)+"s will you drop?";
input @Amount,0,30000;
next;
mes "[^3333FFAthena^000000]";
mes "Please leave a brief reason for this consolation.";
mes "example: Consolation for Zombie Event";
input @reason$;
next;
mes "[^3333FFAthena^000000]";
mes "Consolation : "+getitemname(@itemID)+" ";
mes "Amount : "+@Amount+" ";
mes " ";
mes "Reason:";
mes ""+@reason$+"";
next;
switch(select("Change Consolation","Confirm Consolation","Cancel")) {
case 1:
goto Consolation;
case 2:
mes ""+@Amount+" "+@itemID+"s have been dropped as consolation.";
atcommand "@flooritem "+@itemID+" "+@Amount+"";
set @itemID,query_sql("INSERT INTO `item_consolation` VALUES(NULL,'"+ @charAccNumber +"','"+ strcharinfo(0) +"','"+ @itemID +"','"+ @Amount +"','"+ @N_Itemname$ +"','"+ @reason$ +"','"+ @when$ +"')");
close;
case 3:
goto nvm;
}
}
else {
dispbottom "Sorry, but you do not have permission to access this feature.";
end;
}
}
function script makeTimestamp {
// Get Current Date & Time Variables
set @curYear,gettime(7);
set @curMonth,gettime(6);
set @curDay,gettime(5);
set @curHour,gettime(3);
set @curMinute,gettime(2);
set @curSecond,gettime(1);
// Start A New Timestamp Variable
set @timestamp$,"";
// MySQL Timestamp Friendly :: Year
set @timestamp$,@timestamp$+@curYear+"-";
// MySQL Timestamp Friendly :: Month
if (@curMonth <= 9) {
set @timestamp$,@timestamp$+"0"+@curMonth+"-";
}
else {
set @timestamp$,@timestamp$+@curMonth+"-";
}
// MySQL Timestamp Friendly :: Day
if (@curDay <= 9) {
set @timestamp$,@timestamp$+"0"+@curDay+" ";
}
else {
set @timestamp$,@timestamp$+@curDay+" ";
}
// MySQL Timestamp Friendly :: Hour
if (@curHour <= 9) {
set @timestamp$,@timestamp$+"0"+@curHour+":";
}
else {
set @timestamp$,@timestamp$+@curHour+":";
}
// MySQL Timestamp Friendly :: Minute
if (@curMinute <= 9) {
set @timestamp$,@timestamp$+"0"+@curMinute+":";
}
else {
set @timestamp$,@timestamp$+@curMinute+":";
}
// MySQL Timestamp Friendly :: Second
if (@curSecond <= 9) {
set @timestamp$,@timestamp$+"0"+@curSecond;
}
else {
set @timestamp$,@timestamp$+@curSecond;
}
// Return MySQL Friendly Timestamp
return @timestamp$;
}
Question
Korasu
Original Post:
This is essentially just a small modification to the itemizer release that's been floating around for the last few years, and I'm running across a weird problem that I can't seem to fix.
Script:
I modified it so GMs can access it via whisper, must give a reason, and restructured the log's table in my database for easy reading. In that regard, the NPC works great and does what it's supposed to.
What I recently did was add a menu in the beginning, which would distinguish player prizes from @flooritem consolations. For the Consolation section, I basically duplicated the script and tweaked it a bit to correspond with the log table I made for it. Right now, it freezes completely when I get to this part in either switch:
When I was debugging, I learned that it was likely the callfunc that was screwing things up. I thought maybe the server simply didn't like that there were two callfunc's in the same script, but what do I know - I'm here, aren't I? I tried making a copy of makeTimestamp and naming it makeTimestamp2 (and further defining it in Consolation's callfunc), but that did absolutely nothing.
If anyone has an answer and would like to share it with me, it'd be really helpful and greatly appreciated. Thanks for reading.
Edit: Nevermind, I found the problem myself. There were several errors that didn't show up on my console, and just some poor code structure. I know none of you who initially read this replied, but I'd like to share the final product anyways to help combat GM corruption. This final script works and functions fully as intended.
Link to comment
Share on other sites
2 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.