Re: Players Connected -
Marshall32 - 03.03.2012
Not bad.
Re: Players Connected -
Quinlynn - 03.03.2012
Quote:
Originally Posted by [Cali]ChrOnic_T
Still Fucked up
Код:
//----------------------------------------------------------
// PlayersConnected
// Created: Febuary 7 2012
// By: Marc[Owner]
//----------------------------------------------------------
#include <a_samp>
#include <core>
#include <float>
new PlayersConnected = 0;
public OnFilterScriptInit()
{
print("\n----------------------------------");
print("Running PlayersConnected - by Marc");
print("----------------------------------/n");
return 1;
}
//----------------------------------------------------------
public OnPlayerConnect(playerid)
{
new string[256];
PlayersConnected++;
//PlayersConnected += 1;
format(string, sizeof(string), "(INFO) There are currently %d people in the server!", PlayersConnected);
SendClientMessageToAll(0x00000000, string);
return 1;
}
//----------------------------------------------------------
public OnPlayerDisconnect(playerid, reason)
{
new string[256];
PlayersConnected--;
//PlayersConnected -= 1;
format(string, sizeof(string), "(INFO) There are currently %d people in the server!", PlayersConnected);
SendClientMessageToAll(0x00000000, string);
return 1;
}
//----------------------------------------------------------
Look at the error
Код:
C:\Documents and Settings\EPUser\My Documents\AA- KingJ server Folder\Maps\Conect1.pwn(38) : warning 217: loose indentation
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
1 Warning.
|
It is a warning. Loose Indentation, means that you have a line that is unneeded in it. So in other words delete line 38 and compile again.
Re: Players Connected -
Ash. - 03.03.2012
This script won't be accurate if it's loaded after a player has connected. You should check how many people are connected in OnFilterScriptInit, just incase the script is loaded later rather than when the server starts.
Re: Players Connected -
Deathlane - 03.03.2012
Guys Sorry If I Made It Too Hard Because I Am Still Learning Pawn
Re: Players Connected -
Baboon - 03.03.2012
That string is way tooo big. Change it to 55 (cellseize). Or else you wil loose lots of memory.
Re: Players Connected -
Deathlane - 03.03.2012
I'm too lazy to edit

Sorry.
Re: Players Connected -
Ash. - 04.03.2012
Quote:
Originally Posted by ObelesMarc
I'm too lazy to edit  Sorry.
|
Sorry, but I see no difficulty in this at all.
Re: Players Connected -
Deathlane - 04.03.2012
Edit done to:
new string[128];
Re: Players Connected -
Deathlane - 04.03.2012
Aren't you guys going to recheck it again?
AW: Players Connected -
[N2L]DarkJoker - 04.03.2012
Not Bad.
Re: Players Connected -
Ash. - 04.03.2012
Quote:
Originally Posted by ObelesMarc
Aren't you guys going to recheck it again?
|
Well done, you're now using a sensible cell size.
Now make it check the amount of players that are connected when the filterscript is loaded. This will make the filterscript better overall.
Re: Players Connected -
Deathlane - 05.03.2012
Now... I really don't know how to do that xD
Re: Players Connected -
maylay - 05.03.2012
nice work dude
Re: Players Connected -
Ash. - 05.03.2012
Quote:
Originally Posted by ObelesMarc
Now... I really don't know how to do that xD
|
You'd need to loop through the maximum amount of possible players.
pawn Код:
for(new i; i < GetMaxPlayers(); i++)
You'd then need to check if the player is connected. (Note the normally referred to 'playerid' variable in this case is 'i')
pawn Код:
for(new i; i < GetMaxPlayers(); i++) if(IsPlayerConnected(i))
If that if statement passes, you can then increment the 'PlayersConnected' counter (or whatever you called it, I can't remember).
pawn Код:
for(new i; i < GetMaxPlayers(); i++) if(IsPlayerConnected(i)) PlayersConnected++;
All of that should go in 'OnFilterScriptInit', which is fired when the filterscript is loaded.
Re: Players Connected -
Zxdsl - 05.03.2012
Nice Work Dude
Re: Players Connected -
PawnFox - 05.03.2012
Nice Filterscript.
You could also a Join Messages + Players
example: * imNoob (ID:14) joined the server. Total players: 16
It was a ideea, its good for beginners
AW: Players Connected -
BigETI - 05.03.2012
No need to release it as filterscript.
Quote:
pawn Код:
for(new i; i < GetMaxPlayers(); i++)
|
The most wrongest way of looping through all players.
Use
pawn Код:
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(!IsPlayerConnected(i)) continue;
//...
}
or foreach by ******
pawn Код:
#include <foreach>
//...
foreach(Player, i)
{
//...
}
Re: Players Connected -
RAIDER (RU) - 13.04.2012
It's very simple job (:
Respuesta: Players Connected -
Francis. - 13.04.2012
Why the hell do you need to include gl_common.inc?
By the way, I hate very simple scripts.
Re: Respuesta: Players Connected -
Ash. - 13.04.2012
Quote:
Originally Posted by Francis.
Why the hell do you need to include gl_common.inc?
By the way, I hate very simple scripts.
|
So why post...
It's people like you that scare a way the programming progression that SA-MP needs amongst script development.