Jump to content

Sezonul 3 de Maraton a început. Detalii aici
Fuziunea serverelor de SA-MP. Detalii aici

Sign in to follow this  

[Tutorial] Lista de admini pe baza de iteratori.

Recommended Posts

Bun, pentru inceput aveti nevoie de libraria YSI (mai exact include-ul y_iterate).

#include <YSI\y_iterate>

Acum, trebuie sa definim lista in care adminii vor fi adaugati.

new Iterator: adminsList<MAX_PLAYERS>;

Acum, cand un jucator se conecteaza trebuie sa il adaugam in lista.

P.S: playerVariables[playerid][pAdmin] este variabila facuta in gamemode, nu puneti exact asa daca nu aveti aceasta variabila, inlocuiti cum aveti voi.

public OnPlayerConnect(playerid) {
	if(playerVariables[playerid][pAdmin] >= 1) return Iter_Add(adminsList, playerid);
	return 1;

Acum, cand un jucator se deconecteaza trebuie sa il scoatem din lista.

public OnPlayerDisconnect(playerid, reason) {
	if(playerVariables[playerid][pAdmin] >= 1) return Iter_Remove(adminsList, playerid);
	return 1;

Acum, comanda in sine.

CMD:admins(playerid, params[]) {
    new string[128], numeJucator[MAX_PLAYER_NAME];
  	GetPlayerName(playerid, numeJucator, sizeof numeJucator);
    for(new x : adminsList) {
    	format(string, sizeof string, "[ID %d] %s - admin level %d", x, numeJucator, playerVariables[playerid][pAdmin]);
        SendClientMessage(playerid, -1, string);
    return 1;

Sper ca v-am ajutat, un +1 nu strica :D

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.