SA-MP Forums Archive
Help please - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Help please (/showthread.php?tid=151600)



Help please - bartje01 - 31.05.2010

Well guys, I'm going to work on somethnig I never did before.

I have a question about it.
How can I get the maxplayers that have this?
Код:
if(PlayerInfo[playerid][LSPDLEVEL] >= 1)
Can anyone make an example like this?:

There are [LSPD amount] lspd members online now.


ANd that will show up when you type /lspds.

And you guys should know that this [LSPDLEVEL] >= 1
means that if you are a lspd rank 1 or higher :P
PLease tell me if you don't get my point.
I really need this.

Regards!


Thanks In Advance.


Re: Help please - Grim_ - 31.05.2010

I don't understand correctly.

You're trying to figure out how to tell if an array like
pawn Код:
PlayerInfo[playerid][LSPDLEVEL]
is created and used?


Re: Help please - bartje01 - 31.05.2010

Yea this is a command i'm using:
Код:
dcmd_lspdleader(playerid, params[])
{
 if(PlayerInfo[playerid][Level] >= 1)
  {
   new tmp[256], tmp2[256], Index;
   tmp = strtok(params,Index),
   tmp2 = strtok(params,Index);
   if(!strlen(params)) return SendClientMessage(playerid, red, "USAGE: /lspdleader [playerid]");
   new player1,playername[MAX_PLAYER_NAME], string[128];
   player1 = strval(tmp);
   if(!strlen(tmp2)) return SendClientMessage(playerid, red, "USAGE: /lspdleader [playerid]");

   GetPlayerName(player1,playername,sizeof(playername));

  format(string,sizeof(string),"You have made %s LSPD leader",playername);
  SendClientMessage(playerid,red,string);
	PlayerInfo[player1][LSPDLEVEL] = 10;
	SendClientMessage(player1,red,"You are now lspd leader");
  }
  else SendClientMessage(playerid,red,"You are not an admin");

	return 1;
}



Re: Help please - cAMo - 31.05.2010

Код:
new lspd_online = 0;
for(new i = 0; i < MAX_PLAYERS; i++)
{
	if(PlayerInfo[playerid][LSPDLEVEL] >= 1)
	{
		lspd_online++;
	}
}
format(string, sizeof(string), "There are %d lspd members online now.", lspd_online);
SendClientMessage(playerid, 0xFFFF00AA, string);
I think this is what you are looking for? I didn't test this, but I hope it helps!


Re: Help please - bartje01 - 31.05.2010

I understand tha tyou have to put this at onpalyerconnect hm? xD

And on onplayerisconnect the same but then not + but -



Re: Help please - cAMo - 31.05.2010

Nope. You would put it under OnPlayerCommandText


Re: Help please - Grim_ - 31.05.2010

Well, it depends when you want the message to be sent. If you want it to happen every time someone enters the server, then yes, under OnPlayerConnect().


Re: Help please - bartje01 - 31.05.2010

WWell but when you use that ni a command.
Like /lspds
You get + one player every time you use that command :P


Re: Help please - cAMo - 31.05.2010

Quote:

for(new i = 0; i < MAX_PLAYERS; i++)

Above goes through each player. Below checks to see if the player has >= 1 LSPDLEVEL

Quote:

if(PlayerInfo[playerid][LSPDLEVEL] >= 1)

If that's the case, then it adds 1 lspd_online++

The amount it returns is based on the players online that have >= 1 LSPDLEVEL... not how many times to type the command.



Re: Help please - bartje01 - 31.05.2010

Код:
so this whole code?
Код:
for(new i = 0; i < MAX_PLAYERS; i++)
{
	if(PlayerInfo[playerid][LSPDLEVEL] >= 1)
	{
		lspd_online++;
	}
}
format(string, sizeof(string), "There are %d lspd members online now.", lspd_online);
SendClientMessage(playerid, 0xFFFF00AA, string);
at onplayercommandtext?

I was more like. the counts at onplayerconnect

SO at onplayerconnect:
Код:
for(new i = 0; i < MAX_PLAYERS; i++)
{
	if(PlayerInfo[playerid][LSPDLEVEL] >= 1)
	{
		lspd_online++;
	}
}
Onplayercommandtext:
Код:
commandblabablablal
format(string, sizeof(string), "There are %d lspd members online now.", lspd_online);
SendClientMessage(playerid, 0xFFFF00AA, string);