[FilterScript] Players Connected
#21

Not bad.
Reply
#22

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.
Reply
#23

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.
Reply
#24

Guys Sorry If I Made It Too Hard Because I Am Still Learning Pawn
Reply
#25

That string is way tooo big. Change it to 55 (cellseize). Or else you wil loose lots of memory.
Reply
#26

I'm too lazy to edit Sorry.
Reply
#27

Quote:
Originally Posted by ObelesMarc
Посмотреть сообщение
I'm too lazy to edit Sorry.
Sorry, but I see no difficulty in this at all.
Reply
#28

Edit done to:
new string[128];
Reply
#29

Aren't you guys going to recheck it again?
Reply
#30

Not Bad.
Reply
#31

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.
Reply
#32

Now... I really don't know how to do that xD
Reply
#33

nice work dude
Reply
#34

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.
Reply
#35

Nice Work Dude
Reply
#36

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
Reply
#37

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)
{
    //...
}
Reply
#38

It's very simple job (:
Reply
#39

Why the hell do you need to include gl_common.inc?
By the way, I hate very simple scripts.
Reply
#40

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


Forum Jump:


Users browsing this thread: 4 Guest(s)