Jump to content
  • 0

how to make this script work?


Question

Posted (edited)

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 .@item;
if (getitemname(.@item) == "null") {
mes "Invalid ID "+.@item+".";
close;
}

mes "Input quantity:";
input .@count,0,30000;
if (.@count == 0) {
mes "Invalid quantity 0.";
close;
}

set .@j, query_sql("SELECT `account_id` FROM `char` WHERE `online` = 1",.@aid);
for(set .@i,0; .@i<.@j; set .@i,.@i+1)
getitem .@item,.@count,.@aid[.@i];

mes "Gave item "+getitemname(.@item)+" x"+.@count+" to "+.@j+" players.";
close;
	
Edited by blakbord

9 answers to this question

Recommended Posts

  • 0
Posted (edited)
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
  • 0
Posted

@Fratini
I try to change this line
to .@item

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

and this line
to .@count

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?

  • 0
Posted (edited)

The problem is that when you use the '.@' 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
  • 0
Posted

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

  • 0
Posted

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^

  • 0
Posted

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^

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