Jump to content
  • 0

how to make this script work?


blakbord

Question


  • Group:  Members
  • Topic Count:  30
  • Topics Per Day:  0.01
  • Content Count:  108
  • Reputation:   1
  • Joined:  02/10/12
  • Last Seen:  

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
Link to comment
Share on other sites

9 answers to this question

Recommended Posts

  • 1

  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10013
  • Reputation:   2345
  • Joined:  10/28/11
  • Last Seen:  

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  30
  • Topics Per Day:  0.01
  • Content Count:  153
  • Reputation:   8
  • Joined:  07/01/14
  • Last Seen:  

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
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  30
  • Topics Per Day:  0.01
  • Content Count:  108
  • Reputation:   1
  • Joined:  02/10/12
  • Last Seen:  

@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?

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  30
  • Topics Per Day:  0.01
  • Content Count:  153
  • Reputation:   8
  • Joined:  07/01/14
  • Last Seen:  

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
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  30
  • Topics Per Day:  0.01
  • Content Count:  108
  • Reputation:   1
  • Joined:  02/10/12
  • Last Seen:  

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

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  30
  • Topics Per Day:  0.01
  • Content Count:  153
  • Reputation:   8
  • Joined:  07/01/14
  • Last Seen:  

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^

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  30
  • Topics Per Day:  0.01
  • Content Count:  153
  • Reputation:   8
  • Joined:  07/01/14
  • Last Seen:  

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^

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  30
  • Topics Per Day:  0.01
  • Content Count:  108
  • Reputation:   1
  • Joined:  02/10/12
  • Last Seen:  

@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
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  30
  • Topics Per Day:  0.01
  • Content Count:  153
  • Reputation:   8
  • Joined:  07/01/14
  • Last Seen:  

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

Edited by Fratini
Link to comment
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.

×
×
  • Create New...