Jump to content

Patskie

Community Contributors
  • Content Count

    366
  • Joined

  • Last visited

  • Days Won

    8

Posts posted by Patskie


  1. /*DROP TABLE IF EXISTS `reward_codes`;CREATE TABLE IF NOT EXISTS `reward_codes` (    `code` VARCHAR(10) NOT NULL DEFAULT '',    `nameid` INT(11) UNSIGNED NOT NULL DEFAULT '0',    `item_name` VARCHAR(45) NOT NULL DEFAULT '',    `amount` SMALLINT(6) UNSIGNED NOT NULL DEFAULT '0',    `time_created` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00'    PRIMARY KEY (`code`)) ENGINE = MYISAM;DROP TABLE IF EXISTS `rewardlogs`;CREATE TABLE `rewardlogs` (    `account_id` INT( 10 ) NOT NULL,    `code` VARCHAR( 10 ) NOT NULL,    `redeem_time` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00') ENGINE = MyISAM;*/-    script    promoclaim    -1,{OnInit:    bindatcmd "claim",strnpcinfo(3)+"::OnClaim";    bindatcmd "code",strnpcinfo(3)+"::OnEditCode";    end;    OnClaim:    // if ( getgmlevel() ) end;    mes "^FF0000 Enter a new promotional code.";    input .@pc$;    close2;        query_sql "SELECT `nameid`, `amount` FROM `reward_codes` WHERE `code` = '" + escape_sql(.@pc$) + "'", .@item, .@amt;        if ( !.@item )         dispbottom "Either invalid code or the code is already claimed by other people";    else {        getitem .@item, .@amt;        dispbottom "Promotional code successfully redeemed.";        query_sql "DELETE FROM `reward_codes` WHERE `code` = '" + escape_sql(.@pc$) + "'";        query_logsql "INSERT INTO `rewardlogs` VALUES ( '" + getcharid(3) + "', '" + escape_sql(.@pc$) + "', NOW() )";    }        end;    OnEditCode:    if ( getgmlevel() < 99 ) end;    set .@choice$, "Setup a new promotional code:View existing codes:Delete exisiting codes:Cancel";    setarray .@length, 4,10; // <min>,<max>        switch ( select( .@choice$ ) ) {        case 1:                input .@pcode$;                if ( getstrlen( .@pcode$ ) < .@length[0] || getstrlen( .@pcode$ ) > .@length[1] ) {                        dispbottom "Codes must not be less than " +.@length[0]+ " and must be greater than " +.@length[1]+ ".";                        end;                }                mes "You have entered ^FF0000"+.@pcode$+"^000000 as the code.";                mes "Are you sure?";                if ( select("Yes:No, thanks") - 1 ) end;                query_sql "SELECT `code` FROM `reward_codes` WHERE `code` = '" + escape_sql(.@pcode$) + "'", .@pcode_exists;                if ( .@pcode_exists ) {                        dispbottom "Sorry, that code already exist.";                        end;                }                mes "Please set a reward for the players who has entered the code.";                input .@reward;                next;                if ( !.@reward || getitemname(.@reward) == "null" ) {                        dispbottom "Sorry, that is an invalid item id.";                        end;                }                set .@iname$, getitemname(.@reward);                mes "Item number ^FF0000"+.@reward+"^000000";                mes "is equivalent to ^FF0000"+.@iname$+"^000000.";                mes "Are you sure?";                next;                if ( select("Yes:No, thanks") - 1 ) end;                mes "How many ^FF0000"+.@iname$+"^000000.?";                input .@amount;                next;                if ( !.@amount ) {                    dispbottom "Sorry, that is an invalid amount number.";                    end;                }                mes "Are you sure?";                next;                if ( select("Yes:No, thanks") - 1 ) end;                query_sql "INSERT INTO `reward_codes` VALUES ( '" + escape_sql(.@pcode$) + "', '" + .@reward + "', '" + escape_sql(.@iname$) + "', '" + .@amount + "', NOW() )";                dispbottom "Done creating code!";                break;        case 2:                set .@nb, query_sql("SELECT code, item_name, amount FROM `reward_codes` ORDER BY time_created DESC LIMIT 20", .@code$, .@nid$, .@amount);                    if ( !.@nb ) {                    dispbottom "No exisiting codes.";                    end;                }                dispbottom "=============================================";                dispbottom "==============  EXISITING CODES  ==============";                dispbottom "=============================================";                for(set .@i,0; .@i < .@nb; set .@i,.@i+1)                dispbottom ""+.@code$[.@i]+" (  Reward: "+.@amount[.@i]+" "+.@nid$[.@i]+" ) ";                dispbottom "=============================================";                break;        case 3:                input .@dcode$;                query_sql "SELECT `code` FROM `reward_codes` WHERE `code` = '" + escape_sql(.@dcode$) + "'", .@dcode_exists;                if ( !.@dcode_exists ) {                    dispbottom "Promotional code not found.";                    end;                }                mes "Would you like to delete that code?";                next;                if ( select("Yes:No, thanks") - 1 ) end;                query_sql "DELETE FROM `reward_codes` WHERE `code` = '" + escape_sql(.@dcode$) + "'";                break;        case 4: break;        default: break;    }    close;}

  2. prontera,150,150,0	script	Sample	100,{	if ( countiem( 501 ) < 10 || !countitem( 514 ) ) {		mes "You need 10 apple and 1 grape";		close;	}	if ( !getcharid( 1 ) ) {		mes "You don't have a party";		close;	}	if ( getpartyleader( getcharid( 1 ), 2 ) != getcharid( 0 ) ) {		mes "You must be a party leader";		close;	}	delitem 501, 10;	delitem 514, 1;	warpparty "prontera",150,150,getcharid( 1 );	end;}

  3. Let's try this one : 

    -	script	LuckyPick	-1,{	OnPCLoginEvent:		.aid[getarraysize(.aid)] = getcharid(3);		end;		OnPCLogoutEvent:		for ( .@i = 0; .@i < getarraysize(.aid); .@i++ ) {			if ( .aid[.@i] == getcharid(3) )				deletearray .aid[.@i], 1;		}		end;	OnMinute00:		.@t++;		if ( .@t % 2 ) end;		.@i = rand(getarraysize(.aid));		if (attachrid(.aid[.@i]))			getitem 501, 1, .aid[.@i];		end;}

    @EDIT : Trigger every 2 hours


  4. prontera,150,150,0	script	Sample	100,{	query_sql "SELECT DISTINCT(`account_id`) FROM `char` WHERE `online` = '1'",.@aid;	for ( .@i = 0; .@i < getarraysize(.@aid); .@i++ ) {		if ( attachrid( .@aid[.@i] ) ) {			if ( strcharinfo(3) == "prontera" )				 cutin "kafra_07", 2;		}	}	for ( .@x = 3; .@x > 0; .@x-- ) {		announce "Count down : " +.@x,0;		sleep 1000;	}	for ( .@y = 0; .@y < getarraysize(.@aid); .@y++ ) {		if ( attachrid( .@aid[.@y] ) ) {			if ( strcharinfo(3) == "prontera" )				 cutin "", 255;		}	}	end;}

    Like this?


  5.  

    Might be a good idea to enclose that set for .@r in a do..while loop; if the item name does end up being "null", the user's item is taken and doesn't get anything lol.

     

     

    do {	.@r = rand(501, 700);} while (getitemname(.@r) != "null");

     

    The delitem command is triggered when the item is not null otherwise it does nothing. though i can say a do while loop is a better approach :P

×
×
  • Create New...

Important Information

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