SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 17/02/2010, 11:29 PM   #1
adsy
Huge Clucker
 
Join Date: Aug 2008
Posts: 410
Reputation: 3
Default [FS] Number of Players Online + Last logged in & OUT!

V1.2 NOT WORKING!
1.21 does though

I decided to create a textdraw to show me who is online in terms of numbers at the side of the screen.

This has been tested and is working. Please report bugs in this thread.

NEW: Font height and width to try to fit more in with ease

Purpose: To show you how many players are on your server
AND NOW THE LAST PERSON WHO LOGGED IN!!
ALSO LAST PERSON WHO LOGGED OUT!!
Location of text: Right above the map on the left
Size of text: Readable
Version: 1.21 and not changing (Until I fix that bug)

Number of lines:102
(16 New Lines since V1.0)
(14 New Lines since V1.11)
There are some line gaps you can remove to reduce it

This is the source so pick away please:

pawn Code:
#include <a_samp>
#define SEC1 1000
#define SEC2 2000
#define SEC5 5000

new Text:PlayersOnServer;
new Text:LastPOnServer;
new string[32];
new string2[50];
new PName[MAX_PLAYER_NAME];
new MaxP;
new totalon;
new onoff = 0;

public OnFilterScriptInit()
{
 print("\n--------------------------------------");
 print(" Show Players who are online by Adsy ");
 print("--------------------------------------\n");
 MaxP = GetMaxPlayers();
 drawagain();
 SetTimer("pOnline", SEC2, 1);
 return 1;
}

public OnPlayerConnect(playerid){
 GetPlayerName(playerid, PName, sizeof(PName));
 onoff = 1;
 return 0;
}

public OnPlayerDisconnect(playerid, reason){
 GetPlayerName(playerid, PName, sizeof(PName));
 onoff = 0;
 return 0;
}

public OnFilterScriptExit()
{
  for(new i=0; i<MAX_PLAYERS; i++) {
    TextDrawHideForPlayer(i, PlayersOnServer);
    TextDrawHideForPlayer(i, LastPOnServer);
  }
    return 1;
}

forward drawagain();
public drawagain(){
  if(PlayersOnServer){
    TextDrawDestroy(PlayersOnServer);
  }
  if(LastPOnServer){
    TextDrawDestroy(LastPOnServer);
  }
  format(string, sizeof(string), "%i/%i Online", totalon, MaxP);
  if(onoff == 1){
    format(string2, sizeof(string2), "Last on: %s", PName);
  }
  if(onoff == 0){
    format(string2, sizeof(string2), "Last off: %s", PName);
  }
  PlayersOnServer = TextDrawCreate(30,326, string);
  LastPOnServer = TextDrawCreate(30,318, string2);
  return 0;
}

forward pOnline();
public pOnline(){
  totalon = 0;
  for(new i=0; i<MAX_PLAYERS; i++) {
    if(IsPlayerConnected(i)) {
      if(totalon == 0){
        totalon = 1;
      }
      else if (totalon > 0){
        totalon++;
      }
    }
  }
  drawagain();
  TextDrawFont(PlayersOnServer,2);
  TextDrawUseBox(PlayersOnServer,0);
  TextDrawColor(PlayersOnServer,0xFFFFFFFF);
  TextDrawAlignment(PlayersOnServer, 1);
  TextDrawLetterSize(PlayersOnServer, 0.6, 0.8);
  TextDrawFont(LastPOnServer,1);
  TextDrawUseBox(LastPOnServer,0);
  TextDrawColor(LastPOnServer,0xFFFFFFFF);
  TextDrawAlignment(LastPOnServer, 1);
  TextDrawLetterSize(LastPOnServer, 0.5, 0.8);
  for(new i=0; i<MAX_PLAYERS; i++) {
    if(IsPlayerConnected(i) && GetPlayerInterior(i) < 1) {
      TextDrawShowForPlayer(i, PlayersOnServer);
      TextDrawShowForPlayer(i, LastPOnServer);
    }
    else{
      TextDrawHideForPlayer(i, PlayersOnServer);
      TextDrawHideForPlayer(i, LastPOnServer);
    }
  }
  return 1;
}



NEW IMAGE OF PLAYER GOING OFFLINE COMING SOON!

Downloadable AMX file (just number of players online)
Downloadable AMX file V1.1
Downloadable AMX file V1.11
Downloadable AMX file V1.2 (not working)
Downloadable AMX file V1.21

Temporary bug fix: On entering a mod garage the menu is overlapped slightly so cars with lots of mods can be hard to read at the bottom FIXED.
Issue now arises where player cannot see the textdraw inside any building.

Note: I never delete my files, i may change the location from time to time but ALL posts with a link will be updated to reflect the new download location. As for anyone who just clicks a link, it should always work. In the event that you are unable to download please try again later. If I have any problem with the file server I will try to post in popular topics that the server is having problems.
adsy is offline   Reply With Quote
Old 18/02/2010, 12:57 AM   #2
DiddyBop
Gangsta
 
DiddyBop's Avatar
 
Join Date: Aug 2009
Posts: 666
Reputation: 10
Default Re: [FS] Number of Players Online

Bad spot for the textdraw. people with different resolutions that you made, will make it overlap the chatbox
DiddyBop is offline   Reply With Quote
Old 18/02/2010, 06:34 AM   #3
adsy
Huge Clucker
 
Join Date: Aug 2008
Posts: 410
Reputation: 3
Default Re: [FS] Number of Players Online

From what i understood of the textdraw system, the location was expanded to the correct place depending on your resolution

All textdraws are done in 640X480 resolution so wouldnt that mean all the other boxes would sit in the same places at the right resolutions?

anyway, where would you place it?
adsy is offline   Reply With Quote
Old 18/02/2010, 06:58 AM   #4
V1ceC1ty
Banned
 
Join Date: Oct 2008
Location: West Australia
Posts: 1,896
Reputation: 273
Default Re: [FS] Number of Players Online

Quote:
Originally Posted by adsy
From what i understood of the textdraw system, the location was expanded to the correct place depending on your resolution

All textdraws are done in 640X480 resolution so wouldnt that mean all the other boxes would sit in the same places at the right resolutions?

anyway, where would you place it?
The textdraws wont be in the same place but if you did do it in 640x480 it shouldn't over lap the chat box in any other resolution.
V1ceC1ty is offline   Reply With Quote
Old 18/02/2010, 11:28 AM   #5
adsy
Huge Clucker
 
Join Date: Aug 2008
Posts: 410
Reputation: 3
Default Re: [FS] Number of Players Online

ill change to the resolution and adjust the coordinates as necessary. Thanks for helping clear that up a bit. If no adjustments are required then ill let you know and will have to find out why your getting an overlap.

You debuggers are great for helping me tweak and all comments are greatfully received
adsy is offline   Reply With Quote
Old 18/02/2010, 04:39 PM   #6
adsy
Huge Clucker
 
Join Date: Aug 2008
Posts: 410
Reputation: 3
Default Re: [FS] Number of Players Online

Quote:
Originally Posted by [SP
LilGunna © ]
Bad spot for the textdraw. people with different resolutions that you made, will make it overlap the chatbox
fixed the above:
I have changed the location

I see what you mean.

shame the chat text increases so much more in sizes at lower resolutions

tested script with 2 players, doesnt work.

ill update it in a bit

done! & tested.
adsy is offline   Reply With Quote
Old 18/02/2010, 08:01 PM   #7
Ricop522
High-roller
 
Ricop522's Avatar
 
Join Date: Feb 2010
Location: ES
Posts: 2,640
Reputation: 159
Default Re: [FS] Number of Players Online (Now Working).

I Love you!
How did you find the coordinate of the screen, to create this textdraw? textdraw you with that edict? say? : *?
__________________
"Any fool can write code that a
computer can understand. Good
programmers write code that
humans can understand."

AJUDA! Programação
Github
Ricop522 is offline   Reply With Quote
Old 18/02/2010, 08:01 PM   #8
max1101
Little Clucker
 
Join Date: Dec 2008
Posts: 4
Reputation: 0
Default Re: [FS] Number of Players Online (Now Working).

Nice
max1101 is offline   Reply With Quote
Old 18/02/2010, 08:02 PM   #9
gotenks918
Huge Clucker
 
Join Date: May 2007
Posts: 202
Reputation: 0
Default Re: [FS] Number of Players Online (Now Working).

Doesn't it tell you how many players are on the server when you press tab in the top right...?
gotenks918 is offline   Reply With Quote
Old 18/02/2010, 08:15 PM   #10
Correlli
Godfather
 
Correlli's Avatar
 
Join Date: May 2009
Location: Slovenia
Posts: 6,340
Reputation: 365
Default Re: [FS] Number of Players Online (Now Working).

Quote:
Originally Posted by gotenks918
Doesn't it tell you how many players are on the server when you press tab in the top right...?
Yes, it does.
Correlli 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
Number of faction members online IVuljak Help Archive 2 21/04/2010 10:27 AM
[SOLVED]setting the number of players per team WSD Help Archive 2 17/02/2010 11:54 PM
players online Sampiscool123 Help Archive 2 08/02/2010 02:01 PM
How to make it load a players money from last time he logged in aspire5630 Help Archive 8 15/05/2009 08:56 PM


All times are GMT. The time now is 08:08 AM.


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