• 0
blakbord

how to make this script work?

Question

how can I make this script work? when it reach 100players online it will automatically give an item.. hope that someone can help me? thanks in advance..

mes "Input item ID:";

input [email protected];
if (getitemname([email protected]) == "null") {
mes "Invalid ID "[email protected]+".";
close;
}

mes "Input quantity:";
input [email protected],0,30000;
if ([email protected] == 0) {
mes "Invalid quantity 0.";
close;
}

set [email protected], query_sql("SELECT `account_id` FROM `char` WHERE `online` = 1",[email protected]);
for(set [email protected],0; [email protected]<[email protected]; set [email protected],[email protected]+1)
getitem [email protected],[email protected],[email protected][[email protected]];

mes "Gave item "+getitemname([email protected])+" x"[email protected]+" to "[email protected]+" players.";
close;
	
Edited by blakbord

Share this post


Link to post
Share on other sites

9 answers to this question

Recommended Posts

  • 0
prontera,150,150,3	script	Surprise at 100	832,{

	if(getgmlevel()<80)
		end;
	if(.check==2){
		mes "Sir, the gift was delivered successfully";
		mes "Wanna do it again?";
		switch(select("Yes:No")){
		case 1:
			next;
			goto AGAIN;
			
		case 2:
			close;
		}
	}
	
	AGAIN:
	mes "Input item ID:";

	input .item;
	if(getitemname(.@item) == "null") {
		mes "Invalid ID "+.@item+".";
		close;
	}

	mes "Input quantity:";
	input .count,0,30000;
	if (.@count == 0)
		mes "Invalid quantity 0.";
	close2;
	dispbottom .count+" of "+getitemname(.@item)+" will be given to players as soon as the Server gets 100+ Online =)",0x00FF00;
	set .check,1;
	OnTimer1:
		announce "Congratulation NameRO for reaching 100+ Players !!",bc_all;
		sleep 3000;
		announce "A little gift for each unique player out there!",bc_all;
		if(.check!=2 && .check){
			addrid(0);
			getitem .item,.count;
			detachrid;
			.check = 2;
		}
		end;

}

-	script	Check_100	-1,{
	OnPCLoginEvent:
		if(getusers(1)>=100)
			initnpctimer "Surprise at 100";
		end;

}

I didn't test it. Any problem just post here

 

Edit:

As it can be notice, the NPC that change the ID of the Item gifted and the quantity is in Prontera 150 150. Change that, if you want

Edited by Fratini

Share this post


Link to post
Share on other sites
  • 0

@Fratini
I try to change this line
to [email protected]

input .item;
	if(getitemname(.@item) == "null") {
		mes "Invalid ID "+.@item+".";
		close;
	}

and this line
to [email protected]

input .count,0,30000;
	if (.@count == 0)
		mes "Invalid quantity 0.";
	close2;
	dispbottom .count+" of "+getitemname(.@item)+" will be given to players as soon as the Server gets 100+ Online =)",0x00FF00;

and this line too
if(getusers(1) == 5) so I can get the item easily

-	script	Check_100	-1,{
	OnPCLoginEvent:
		if(getusers(1)>=100)
			initnpctimer "Surprise at 100";
		end;

}

but still not giving the item as the reward?

Share this post


Link to post
Share on other sites
  • 0

The problem is that when you use the '[email protected]' sufix, the values will be gone when the script ends. They're not stored. You have to use the '.' to store the values on the NPC variable.


I see that I made some mistakes. I think now It will work:

prontera,150,150,3	script	Agent#GiftOnline	832,{

	if(getgmlevel()<80)
		end;
	if(.check==2){
		mes "Sir, the gift was delivered successfully";
		mes "Wanna do it again?";
		switch(select("Yes:No")){
		case 1:
			next;
			goto AGAIN;
			
		case 2:
			close;
		}
	}
	
	AGAIN:
	mes "Input item ID:";

	input .item;
	if(getitemname(.item) == "null") {
		mes "Invalid ID "+.item+".";
		close;
	}

	mes "Input quantity:";
	input .count,0,30000;
	if (.count == 0)
		mes "Invalid quantity 0.";
		
	mes "Input the minimum number of Players Online";
	input .@i,1,500;
	getvariableofnpc(.number,"Check_Players")
	close2;
	dispbottom .count+" of "+getitemname(.item)+" will be given to players as soon as the Server gets "+.@i+"+ Online =)",0x00FF00;
	set .check,1;
	end;
	
	OnTimer1:
		set .@j,getvariableofnpc(.number,"Check_Players");
		announce "Congratulation NameRO for reaching "+.@j+"+ Players !!",bc_all;
		sleep 3000;
		announce "A little gift for each unique player out there!",bc_all;
		if(.check!=2 && .check){
			addrid(0);
			getitem .item,.count;
			detachrid;
			.check = 2;
		}
		end;

}

-	script	Check_Players	-1,{
	OnPCLoginEvent:
		if(getusers(1)>=.number && .number>0)
			initnpctimer "Agent#GiftOnline";
		end;

}

 

1 hour ago, blakbord said:

if(getusers(1) == 5) so I can get the item easily

So, to test it I add a variable to easily edit the number of players that the script will give the item of choice

Edited by Fratini

Share this post


Link to post
Share on other sites
  • 0

it's working now, but the problem is this line..

announce "Congratulation NameRO for reaching "+.@j+"+ Players !!",bc_all;

it announces Congratulation NameRO for reaching 0+ Players..
why does the script announce 0 Players?

 

and every time I relog in the game, the script spam announcing.. even though I'm the only player..

Share this post


Link to post
Share on other sites
  • 0

Try that:

 

prontera,150,150,3	script	Agent#GiftOnline	832,{

	if(getgmlevel()<80)
		end;
	if(.check==2){
		mes "Sir, the gift was delivered successfully";
		mes "Wanna do it again?";
		switch(select("Yes:No")){
		case 1:
			next;
			goto AGAIN;
			
		case 2:
			close;
		}
	}
	
	AGAIN:
	mes "Input item ID:";

	input .item;
	if(getitemname(.item) == "null") {
		mes "Invalid ID "+.item+".";
		close;
	}

	mes "Input quantity:";
	input .count,0,30000;
	if (.count == 0)
		mes "Invalid quantity 0.";
		
	mes "Input the minimum number of Players Online";
	input .@i,1,500;
	getvariableofnpc(.number,"Check_Players")
	close2;
	dispbottom .count+" of "+getitemname(.item)+" will be given to players as soon as the Server gets "+.@i+"+ Online =)",0x00FF00;
	set .check,1;
	end;
	
	OnTimer1:
		set .@j,getvariableofnpc(.number,"Check_Players");
		if(!.@j){
			stopnpctimer;
			end;
		}
		announce "Congratulation NameRO for reaching "+.@j+"+ Players !!",bc_all;
		sleep 3000;
		announce "A little gift for each unique player out there!",bc_all;
		if(.check!=2 && .check){
			addrid(0);
			getitem .item,.count;
			detachrid;
			.check = 2;
		}
		stopnpctimer;
		end;

}

-	script	Check_Players	-1,{
	OnPCLoginEvent:
		if(getusers(1)>=.number && .number>0)
			initnpctimer "Agent#GiftOnline";
		end;

}

Remember to completely change the script. Delete the old one and add these^

Share this post


Link to post
Share on other sites
  • 0

Try that:

 

prontera,150,150,3	script	Agent#GiftOnline	832,{

	if(getgmlevel()<80)
		end;
	if(.check==2){
		mes "Sir, the gift was delivered successfully";
		mes "Wanna do it again?";
		switch(select("Yes:No")){
		case 1:
			next;
			goto AGAIN;
			
		case 2:
			close;
		}
	}
	
	AGAIN:
	mes "Input item ID:";

	input .item;
	if(getitemname(.item) == "null") {
		mes "Invalid ID "+.item+".";
		close;
	}

	mes "Input quantity:";
	input .count,0,30000;
	if (.count == 0)
		mes "Invalid quantity 0.";
		
	mes "Input the minimum number of Players Online";
	input .@i,1,500;
	getvariableofnpc(.number,"Check_Players")
	close2;
	dispbottom .count+" of "+getitemname(.item)+" will be given to players as soon as the Server gets "+.@i+"+ Online =)",0x00FF00;
	set .check,1;
	end;
	
	OnTimer1:
		set .@j,getvariableofnpc(.number,"Check_Players");
		if(!.@j){
			stopnpctimer;
			end;
		}
		announce "Congratulation NameRO for reaching "+.@j+"+ Players !!",bc_all;
		sleep 3000;
		announce "A little gift for each unique player out there!",bc_all;
		if(.check!=2 && .check){
			addrid(0);
			getitem .item,.count;
			detachrid;
			.check = 2;
		}
		stopnpctimer;
		end;

}

-	script	Check_Players	-1,{
	OnPCLoginEvent:
		if(getusers(1)>=.number && .number>0)
			initnpctimer "Agent#GiftOnline";
		end;

}

Remember to completely change the script. Delete the old one and add these^

Share this post


Link to post
Share on other sites
  • 0

@Fratini thanks for helping.. I appreciate it so much..
@Emistry your script works perfectly, thank you..

thanks for the both of you guys..

Edited by blakbord
solved

Share this post


Link to post
Share on other sites
  • 0

No problem, @blakbord !
Don't forget to keep moving! Problems and errors are signs of growing

Edited by Fratini

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.   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.

Loading...