SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 11/08/2017, 08:57 PM   #1
RedGun2015
Big Clucker
 
Join Date: Sep 2015
Posts: 118
Reputation: 0
Default Players on single line

Hello, i want to send to all players a message like this:
Code:
Andrew was kicked by AdmBot for being AFK for more then 30 minutes.
And when more players are afk, something like this:
Code:
Andrew, Forech, Marius, Leed were kicked by AdmBot for being AFK for more then 30 minutes.
In my script when more then 1 player goes kick by admbot for being afk, appears like this:
Code:
Andrew was kicked by AdmBot for being AFK for more then 30 minutes.
Forech was kicked by AdmBot for being AFK for more then 30 minutes.
Marius was kicked by AdmBot for being AFK for more then 30 minutes.
Leed was kicked by AdmBot for being AFK for more then 30 minutes.
i want in one line, no in 4,5,1000.

My script: https://pastebin.com/AAGrBwAH
RedGun2015 is offline   Reply With Quote
Old 11/08/2017, 10:17 PM   #2
HoussamMaroc
Big Clucker
 
HoussamMaroc's Avatar
 
Join Date: Aug 2016
Location: Moroccan
Posts: 67
Reputation: 28
Default Re: Players on single line

No One Can Do THAT Bro Sorry
HoussamMaroc is offline   Reply With Quote
Old 11/08/2017, 10:32 PM   #3
Misiur
High-roller
 
Misiur's Avatar
 
Join Date: Jul 2009
Location: Poland
Posts: 2,293
Reputation: 485
Default Re: Players on single line

We can help you only if you show some effort, try coding something. This is not a place for script requesting.
Misiur is online now   Reply With Quote
Old 11/08/2017, 11:33 PM   #4
RedGun2015
Big Clucker
 
Join Date: Sep 2015
Posts: 118
Reputation: 0
Default Re: Players on single line

Sorry, i tried something like this, but is show me only players that has been kicked, the message "was kicked by AdmBot ..." doesn't appear.

HTML Code:
new out,tmp[128];
		gString[0] = (EOS);
		foreach(new i : Player)
		{
			if(IsPlayerConnected(i))
			{
				if(IsBot[i] == 0)
				{
					if(PlayerInfo[i][pSleeping] == 0)
					{
						if(IsPlayerAFK[i] == 300) //1680
						{
							SS(i, COLOR_LIGHTRED, "Daca nu te misti vei primi kick in 2 minute.", "If you don't move you will be kicked in 2 minutes.");
						}
						if(IsPlayerAFK[i] >= 400) //1800
						{
							SS(i, COLOR_WHITE, "Ai primit kick pentru ca ai fost AFK mai mult de 30 de minute.", "You were kicked for being AFK (away from keyboard) for more than 30 minutes.");
							SS(i, COLOR_WHITE, "Pentru a-ti lasa caracterul AFK mai mult de 30 de minute, foloseste /sleep intr-o casa.", "To leave your character AFK for longer than 30 minutes, use /sleep in a house.");
							SendClientMessage(i, COLOR_GENANNOUNCE, "You have been kicked for being AFK.");
							out++;
							if( out > 0 ) format(tmp,sizeof(tmp),"%s, ",GetName(i));
							strcat(gString,tmp);
							new var100[300];
							mysql_format(SQL, var100, sizeof(var100), "INSERT INTO kicklogs (`playerid`,`giverid`,`playername`,`givername`,`reason`) VALUES ('%d','3','%s','AdmBot','AFK for more than 30 minutes')", PlayerInfo[i][pSQLID],PlayerInfo[i][pNormalName]);
							mysql_tquery(SQL,var100,"","");
							KickEx(i);
						}
					}
				}
			}
		}
		if(out > 1) strcat(tmp, " were kicked by AdmBot for being AFK without sleep for more than 30 minutes.");
		if(out == 1) strcat(tmp, " was kicked by AdmBot for being AFK without sleep for more than 30 minutes.");
		if(out > 0) {
			SendClientMessageToAll(COLOR_LIGHTRED, gString);
		}
RedGun2015 is offline   Reply With Quote
Old 12/08/2017, 12:13 AM   #5
Misiur
High-roller
 
Misiur's Avatar
 
Join Date: Jul 2009
Location: Poland
Posts: 2,293
Reputation: 485
Default Re: Players on single line

It's good, except near the end:
Code:
if(out > 1) strcat(tmp, " were kicked by AdmBot for being AFK without sleep for more than 30 minutes.");
if(out == 1) strcat(tmp, " was kicked by AdmBot for being AFK without sleep for more than 30 minutes.");
if(out > 0) {
  SendClientMessageToAll(COLOR_LIGHTRED, gString);
}
You add to "tmp" variable, but send "gString". Choose one of them
Misiur is online now   Reply With Quote
Old 12/08/2017, 12:33 AM   #6
Jefff
High-roller
 
Join Date: Dec 2007
Posts: 2,585
Reputation: 294
Default Re: Players on single line

and what when there will be more than few players? SCM can send 144 characters ;d
Jefff is offline   Reply With Quote
Old 12/08/2017, 09:26 AM   #7
RedGun2015
Big Clucker
 
Join Date: Sep 2015
Posts: 118
Reputation: 0
Default Re: Players on single line

I try, but is appear something like this
Code:
Andrew, was kicked by AdmBot for being AFK more then 30 minutes.
With more players
Code:
Andrew, Leon, Grown, was kicked by AdmBot for being AFK more then 30 minutes.
I want no comma at the end of the last player
RedGun2015 is offline   Reply With Quote
Old 12/08/2017, 09:30 AM   #8
Arthur Kane
Gangsta
 
Join Date: Sep 2012
Posts: 649
Reputation: 26
Default Re: Players on single line

You could just compile all the names into a singular string.

Code:
format(sendString, 128, "%s, %s, %s", firstName, secondName, thirdName);
Just a thought.
Arthur Kane is offline   Reply With Quote
Old 12/08/2017, 09:38 AM   #9
Misiur
High-roller
 
Misiur's Avatar
 
Join Date: Jul 2009
Location: Poland
Posts: 2,293
Reputation: 485
Default Re: Players on single line

Alright, so all you have to do is to remove the last comma:
Code:
if(out > 0) {
  new len = strlen(str);
  tmp[len - 2] = EOS;
}
if(out > 1) strcat(tmp, " were kicked by AdmBot for being AFK without sleep for more than 30 minutes.");
if(out == 1) strcat(tmp, " was kicked by AdmBot for being AFK without sleep for more than 30 minutes.");
if(out > 0) {
  SendClientMessageToAll(COLOR_LIGHTRED, tmp);
}
Misiur is online now   Reply With Quote
Old 12/08/2017, 12:02 PM   #10
RedGun2015
Big Clucker
 
Join Date: Sep 2015
Posts: 118
Reputation: 0
Default Re: Players on single line

Now is just show 1 name
RedGun2015 is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
I'm getting 4 errors on a single line .[Help would be appriciated] Desi_Dude Scripting Help 2 06/02/2013 10:46 AM
this one single line crashes my complete compiler(showplayerdialog) niels44 Scripting Help 5 15/12/2012 06:43 PM
Random Client message (not a single line) SnG.Scot_MisCuDI Scripting Help 3 28/07/2012 01:00 AM
Help with single line kaiks Scripting Help 2 28/06/2012 07:58 AM
Get Integers in a Single Line zallomallo Help Archive 1 29/06/2009 05:48 PM


All times are GMT. The time now is 04:35 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.