SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 19/10/2014, 05:36 PM   #1
ShoortyFl
Huge Clucker
 
Join Date: Apr 2014
Location: Malibu, CA
Posts: 336
Reputation: 16
Default Offline and Online Members

How can i create something like this, when leader types /allmembers or something like that something like this shows up:




So basically it shows up all players that are in organisation/faction and shows if they're online or offline.


I'm using mysql.
ShoortyFl is offline   Reply With Quote
Old 19/10/2014, 07:26 PM   #2
ShoortyFl
Huge Clucker
 
Join Date: Apr 2014
Location: Malibu, CA
Posts: 336
Reputation: 16
Default Re: Offline and Online Members

Anyone ?
ShoortyFl is offline   Reply With Quote
Old 19/10/2014, 07:49 PM   #3
Kaperstone
Banned
 
Join Date: May 2011
Location: Russia
Posts: 3,004
Reputation: 824
Default Re: Offline and Online Members

You can do this either by account/user id or username.
Fetch the member list and get the neccesary data (account/user id or username) after then run a loop through all online players and check if their account id / username matches, if it does then this member is connected.

Then collect all of that data and run another loop at the end (seperated) which will output all the members and at the end of the format you can use ternary operator (online==1 ? "online" : "offline").

Hope you understood
Kaperstone is offline   Reply With Quote
Old 19/10/2014, 07:59 PM   #4
ShoortyFl
Huge Clucker
 
Join Date: Apr 2014
Location: Malibu, CA
Posts: 336
Reputation: 16
Default Re: Offline and Online Members

Actually no, I'm new to pwn, only know php so far
ShoortyFl is offline   Reply With Quote
Old 19/10/2014, 10:20 PM   #5
ShoortyFl
Huge Clucker
 
Join Date: Apr 2014
Location: Malibu, CA
Posts: 336
Reputation: 16
Default Re: Offline and Online Members

anyone ?
ShoortyFl is offline   Reply With Quote
Old 19/10/2014, 10:22 PM   #6
Abagail
High-roller
 
Join Date: Dec 2013
Location: GetPlayerPos(playerid, pos); Scripter/Mapper.
Posts: 3,133
Reputation: 445
Default Re: Offline and Online Members

Are you using MySQL or .ini? You need to be more descriptive when asking for help.
Abagail is offline   Reply With Quote
Old 19/10/2014, 11:10 PM   #7
Mark_Weston
Gangsta
 
Mark_Weston's Avatar
 
Join Date: Aug 2010
Location: Winnipeg, Manitoba, Canada
Posts: 952
Reputation: 70
Default Re: Offline and Online Members

Quote:
Originally Posted by Abagail View Post
Are you using MySQL or .ini? You need to be more descriptive when asking for help.
He clearly mentioned MySQL bruh
Mark_Weston is offline   Reply With Quote
Old 19/10/2014, 11:21 PM   #8
Abagail
High-roller
 
Join Date: Dec 2013
Location: GetPlayerPos(playerid, pos); Scripter/Mapper.
Posts: 3,133
Reputation: 445
Default Re: Offline and Online Members

Quote:
Originally Posted by Mark_Weston View Post
He clearly mentioned MySQL bruh
Didn't notice. Lmao.

On-Topic:
This should help. Change it to fit with your system/variables.

pawn Code:
mysql_format(MySQLCon, query, sizeof(query), "SELECT * FROM `players` WHERE `faction` = '%d'", pInfo[playerid][faction]);
mysql_tquery(MySQLCon, query, "", "");
new numrows = cache_get_rows();
new username[MAX_PLAYER_NAME], string[128];
if(numrows > 0)
{
     for(new i; i < numrows; i++)
     {
           cache_get_field_content(i, "Username", username, 1, sizeof(username));
           if(ReturnUser(username)) {
            format(string, sizeof(string), "%s[ONLINE]", username);
            return SendClientMessage(playerid, -1, string);
           }
           format(string, sizeof(string), "%s[OFFLINE]", username);
           SendClientMessage(playerid, -1, string);
     }
}

This should work how-ever I did it fast so it might have mistakes.
Abagail is offline   Reply With Quote
Old 19/10/2014, 11:33 PM   #9
ShoortyFl
Huge Clucker
 
Join Date: Apr 2014
Location: Malibu, CA
Posts: 336
Reputation: 16
Default Re: Offline and Online Members

C:\Users\Nathan\Desktop\Server\Server\gamemodes\rp fa.pwn(5306) : error 017: undefined symbol "cache_get_rows"
C:\Users\Nathan\Desktop\Server\Server\gamemodes\rp fa.pwn(5313) : error 017: undefined symbol "ReturnUser"

my Mysql version is R38.
ShoortyFl is offline   Reply With Quote
Old 19/10/2014, 11:50 PM   #10
ShoortyFl
Huge Clucker
 
Join Date: Apr 2014
Location: Malibu, CA
Posts: 336
Reputation: 16
Default Re: Offline and Online Members

Sorry for DP but this gives me no errors in Pawno, but in mysql log it says

cache_get_data - no active cache

Code
pawn Code:
CMD:allmembers(playerid, params[])
{
    new szRows, szFields, query[128];
    mysql_format(konekt, query, sizeof(query), "SELECT * FROM `Igraci` WHERE `Clan` = '%d'", PI[playerid][Clan]);
    mysql_tquery(konekt, query, "", "");
    cache_get_data(szRows, szFields);
    new username[MAX_PLAYER_NAME], string[128];
    if(szRows)
    {
         for(new i; i < szRows; i++)
         {
               cache_get_field_content(i, "Ime", username, 1, sizeof(username));
               if(ReturnUser(username)) {
                format(string, sizeof(string), "%s[ONLINE]", username);
                return SendClientMessage(playerid, -1, string);
               }
               format(string, sizeof(string), "%s[OFFLINE]", username);
               SendClientMessage(playerid, -1, string);
         }
    }
    return 1;
}
ShoortyFl 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
HELP - Members Faction Online Steveproxy5 Scripting Help 4 03/08/2014 01:19 PM
Checking offline members MadafakaPro Scripting Help 6 12/03/2013 05:33 PM
[HELP] View all team-members online Fredden1993 Scripting Help 3 26/12/2011 12:08 AM
kick offline members Tanush123 Help Archive 12 20/08/2011 04:06 AM
Number of faction members online IVuljak Help Archive 2 21/04/2010 10:27 AM


All times are GMT. The time now is 03:01 PM.


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