SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 17/03/2014, 05:39 AM   #1
Kyance
Gangsta
 
Kyance's Avatar
 
Join Date: Mar 2013
Posts: 817
Reputation: 92
Default Looping trough online AND OFFLINE players

I've seen some players which have 'feature', that loops trough offline players or invalid vehicles or w.e ( Stunt, DM, Roleplay etc.. )

Some examples:
Special "weapons"
Special vehicles
Maps or w.e

So, eh, how can you exactly do this?;d
__________________
I'm amazed how you people are still wasting your time on a decade old game.
Kyance is offline   Reply With Quote
Old 17/03/2014, 06:21 AM   #2
BigETI
Banned
 
Join Date: Mar 2010
Location: Germany
Posts: 1,046
Reputation: 359
Default AW: Looping trough online AND OFFLINE players

By using databases for your server.
BigETI is offline   Reply With Quote
Old 17/03/2014, 06:28 AM   #3
Kyance
Gangsta
 
Kyance's Avatar
 
Join Date: Mar 2013
Posts: 817
Reputation: 92
Default Re: AW: Looping trough online AND OFFLINE players

Quote:
Originally Posted by BigETI View Post
By using databases for your server.
I don't have a server, i just want to test some stuff out.
Well.. let's take "Y_INI" for an example( which i use ), how can you create something like an "Auto Enabled Anti-Cheat"? xd
__________________
I'm amazed how you people are still wasting your time on a decade old game.
Kyance is offline   Reply With Quote
Old 17/03/2014, 11:58 AM   #4
Kyance
Gangsta
 
Kyance's Avatar
 
Join Date: Mar 2013
Posts: 817
Reputation: 92
Default Re: Looping trough online AND OFFLINE players

Quote:
Originally Posted by [HLF]Southclaw View Post
"Looping" is sort of the wrong term, unless player data is stored in runtime memory (not advisable!)

It really depends on what you want to do: check something on each user account? Update something on each user account? It also depends on how you store the data: relational database, flat file database, INI/JSON/Binary?

I'm not sure what you mean by the last thing, y_ini is a file parser and pretty unrelated to anti-cheat.
Update something.
It's saved as a .ini file.
Well, that was just an example i wanted to give out.

For an example:
pawn Code:
SetTimer("AllowTeleport", 55555, true); //Random timer

forward AllowTeleport();
public AllowTeleport()
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        blabla{ i } = true;
        //Something which includes offline players
    }
    return 1;
}


CMD:teleport(playerid, params[]) {
    if(blabla{ playerid })
    {
        //other stuff here
    }
    return 1;
}

Or something like that.
__________________
I'm amazed how you people are still wasting your time on a decade old game.
Kyance is offline   Reply With Quote
Old 17/03/2014, 01:48 PM   #5
Kyance
Gangsta
 
Kyance's Avatar
 
Join Date: Mar 2013
Posts: 817
Reputation: 92
Default Re: Looping trough online AND OFFLINE players

Quote:
Originally Posted by [HLF]Southclaw View Post
You can't really mix offline and online players in the same code without some abstraction and probably even a database. Online players are referenced by a volatile player ID (inconsistent) and offline players are likely referenced by their username. To get around this, you'd need some form of global ID that is unique to each player. But for this to be effective, a database would really be needed (rowid can be used as the unique player ID)

With a basic y_ini system, you'd need some form of user list or a directory-listing plugin in order to perform an action on each file. There's no native way to read the files in a directory with the default SA:MP/Pawn libraries so you'll either need a file that contains a list of every registered user that appends a name each time a new user registers. You could look into y_users which is a user system built on top of y_ini. I haven't used it much but I think that system has some way of searching existing users.
Alright.. thanks, will try out something then
__________________
I'm amazed how you people are still wasting your time on a decade old game.
Kyance 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
Looping Through Players Glint Scripting Help 10 30/08/2012 09:28 AM
Loop trough all players except one BlackWolf120 Help Archive 3 18/01/2011 02:29 PM
Looping through all the players? mrcoolballs Help Archive 2 07/09/2010 06:45 AM
how can i know if my server is online or offline? sandisk125 Server Support 7 04/08/2009 06:09 AM


All times are GMT. The time now is 06:22 AM.


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