Jump to content
  • 0

User Online Roulette Script don't work right, need help.


Question

Posted
//=============================================================//
// Daily Card for Online User	                               //
//==== Copyright ==============================================//
// Innos '2017 for www.ex-RO.de                                //
//==== Version ================================================//
// V.1.0 - Testversion										   //
//==== Infos ==================================================//
// Special daily Event for Daily Card from 12a.m. to 10p.m.    //
//=============================================================//

-	script	Daily Card	-1,{

Onclock1125:
Onclock1130:
Onclock1135:
Onclock1140:
.onlineusers = getusers(1);
announce "[Day Card] : "+.onlineusers+" Player online!",bc_all,0xFF6060;
if(.onlineusers < 5) {	announce "[Day Card] : Zu wenig Spieler Online für eine Auslosung!",bc_all,0xFF6060; }
if(.onlineusers > 5) {
	announce "[Day Card] : Es wird eine Zahl von 1 bis 9 gewürfelt, liegt sie unter "+.onlineusers+" kommt es zur Auslosung!",bc_all,0xFF6060;
	set .dailynumber,rand (1,9);
	announce "[Day Card] : Die Zahl ist: "+.dailynumber+"!",bc_all,0xFF6060;
	
	if (.dailynumber < .onlineusers) {
	announce "Karte wird ausgespielt!",bc_all,0x81BEF7; 

                query_sql "SELECT `account_id` FROM `char` WHERE `online` = '1' ORDER BY `account_id` ASC",.@aid;
                if(!.@aid){ end; }

				for(set .@i,0; .@i < getarraysize(.@aid); set .@i,.@i+1)
                {
                        set .@total,.@i;
                }
				
                set .rand3,rand(.@total);
				
                for(set .@i,0; .@i < getarraysize(.@aid); set .@i,.@i+1)
                {
                        if (attachrid(.@aid[.rand3])) {
                                getitem 501,1;
                        }
                }
                
				//why the users get the item value from usersonline count? they should only get one item -.-
                announce "TEST TEST TEST KEIN GEWINN//Der Gewinner der Day Card "+.@daycard$+" ist "+rid2name(.@aid[.rand3])+"! Gratulation!",bc_all;
//				query_sql ("INSERT INTO `daily_card` (time_created,nameid,item_name,account_id,char_name) VALUES (NOW(), '"+.items+"', '"+.@daycard$+"', '"+.rand3+"', '"+rid2name(.@aid[.rand3])+"')");
				end;
	}else{
	announce "Karte wird leider nicht ausgespielt!",bc_all,0x81BEF7; end;
	}
}

//OnInit:
        
//				if (gettime(4)==0){ set .items,501; set .@daycard$, "Sonntag"; }
//				if (gettime(4)==1){ set .items,501; set .@daycard$, "Montag"; }
//				if (gettime(4)==2){ set .items,501; set .@daycard$, "Dienstag"; }
//				if (gettime(4)==3){ set .items,501; set .@daycard$, "Mittwoch"; }
//				if (gettime(4)==4){ set .items,501; set .@daycard$, "Donnerstag"; }
//				if (gettime(4)==5){ set .items,501; set .@daycard$, "Freitag"; }
//				if (gettime(4)==6){ set .items,501; set .@daycard$, "Samstag"; }
//		end;
}

//SQL for Log
/*
DROP TABLE IF EXISTS `daily_card`;
CREATE TABLE IF NOT EXISTS `daily_card` (
  `time_created` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
  `nameid` INT(11) UNSIGNED NOT NULL DEFAULT '0',
  `item_name` VARCHAR(45) NOT NULL DEFAULT '',
  `account_id` INT(11) UNSIGNED NOT NULL DEFAULT '0',
  `char_name` VARCHAR(45) NOT NULL DEFAULT '',
  PRIMARY KEY (`time_created`)
) ENGINE=MYISAM;

query_sql ("INSERT INTO `daily_card` (time_created,nameid,item_name,account_id,char_name) VALUES ('NOW(), "+.@reward+", '"+@daycard$+"', '0', '0')");

*/

//===============================================================================

 

I have a problem with my script. The Online User who wins becomes more than 1 Item. Why?  I want that the User become only 1. In this Test it's a Red Potion. The Winner becomes so many Red Potion are Users Online. If 10 Users online he becomes 10.

This Script should a simple Roulette. At a Full Hour he dice, if the Dice under the Online Count a random Online User becomes a Item. Very Simple. But it don't work correctly.

 

What's my failure?

 

ignore the SQL entry's, this only log for later.

2 answers to this question

Recommended Posts

  • 0
Posted
for(set .@i,0; .@i < getarraysize(.@aid); set .@i,.@i+1)
{
	if (attachrid(.@aid[.rand3])) {
		getitem 501,1;
	}
}

change to


	if (attachrid(.@aid[.rand3])) {
		getitem 501,1;
	}

 

  • Like 1

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.   Paste as plain text instead

  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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...