Looping trough online AND OFFLINE players
#1

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

By using databases for your server.
Reply
#3

Quote:
Originally Posted by BigETI
Посмотреть сообщение
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
Reply
#4

Quote:
Originally Posted by [HLF]Southclaw
Посмотреть сообщение
"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 Код:
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.
Reply
#5

Quote:
Originally Posted by [HLF]Southclaw
Посмотреть сообщение
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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)