PDA

View Full Version : Help


RarKiiNG
29/07/2018, 12:19 AM
Hello, i wanna make a cmd, when i use a command in chat the cmd start to do this:'/id 0'... '/id 1' ... '/id 2' .... '/id 3'....etc ... '/id 999'.
i am new i scripting. please help me.

Leaky
29/07/2018, 03:03 AM
what i would do is make a loop through all the players and them make a function which collects the players information that i want to be displayed and send it in the command, in other words somthing like a /admins command with a little more features.

CMD:admins(playerid)
{
new count = 0;
SendClientMessage(playerid, 0x3776CCFF, " Players Information");
foreach(new i : Player)
{
string[128];
format(string, sizeof(string), "%s ", Sendinfo(i));// you will need to edit this line if you dont want to make a function to collect the information and just rather to paste the long code here.
SendClientMessage(playerid,-1,string)
count ++;
}
if(count <= 1)
{
SendClientMessage(playerid,-1,"No Players Online");
}
return 1;
}

Note that if you use the function "Sendinfo" you will have to create/define it because i didn't make or if you are too lazy to make the function you will have to paste the long code to collect the information in the format line.

Now all you need to do is build the function which is pretty easy to do

coool
29/07/2018, 05:33 AM
Hello, i wanna make a cmd, when i use a command in chat the cmd start to do this:'/id 0'... '/id 1' ... '/id 2' .... '/id 3'....etc ... '/id 999'.
i am new i scripting. please help me.
I can not understand you. but maybe you are looking about sscanf.
what i would do is make a loop through all the players and them make a function which collects the players information that i want to be displayed and send it in the command, in other words somthing like a /admins command with a little more features.

CMD:admins(playerid)
{
new count = 0;
SendClientMessage(playerid, 0x3776CCFF, " Players Information");
foreach(new i : Player)
{
string[128];
format(string, sizeof(string), "%s ", Sendinfo(i));// you will need to edit this line if you dont want to make a function to collect the information and just rather to paste the long code here.
SendClientMessage(playerid,-1,string)
count ++;
}
if(count <= 1)
{
SendClientMessage(playerid,-1,"No Players Online");
}
return 1;
}

Note that if you use the function "Sendinfo" you will have to create/define it because i didn't make or if you are too lazy to make the function you will have to paste the long code to collect the information in the format line.

Now all you need to do is build the function which is pretty easy to do
This is completely irrelevant to OP. Instead of creating a variable "count" you can use Iter_count.