Jump to content

Sistem admin


IosifR

Recommended Posts

Re. E foarte simplu sa faci acest lucrul doar ca uni dintre cei noi in scripting nu stiu cum. e a

Primadata mergem la enum pInfo sau cum aveti voi.

enum pInfo {
	// Ce aveti voi, 
	pAdmin
}

Acum, mergem la OnLogin sau OnPlayerLogin depinde cum aveti voi in gamemode. Inainte de SpawnPlayer(playerid); puneti 

PlayerInfo[playerid][pAdmin] = cache_get_field_content_int(0, "Admin");

Acum trebuie sa facem comanda cu care adminul va oferi admin.

CMD:setadmin(playerid, params[])
{
	if(PlayerInfo[playerid][pAdmin] < 6)
		return SendClientMessage(playerid, 0xB1BFCC80, "Eroare: Nu ai gradul administrativ necesar.");
	
	new id, admin, string[64];
	if(sscanf(params, "ud", id, admin))
		return SendClientMessage(playerid, 0xB1BFCC80, "SYNTAX: /setadmin <ID/Name> <Admin Level (0-7)>");
	
	if(admin < 0 || admin > 7)
		return SendClientMessage(playerid, -1, "Invalid Admin Level.");
	
	format(string, sizeof(string), "Felicitari! Ai fost promovat la admin %d.", admin);
	SendClientMessage(id, -1, string);
	
	new query[100];
	PlayerInfo[playerid][pAdmin] = admin;
	mysql_format(SQL, query, sizeof(query), "UPDATE `users` SET `Admin` = '%d' WHERE `ID` = '%d'", PlayerInfo[playerid][pAdmin], PlayerInfo[playerid][pSQLID]);
	mysql_tquery(SQL, query);
	
	return 1;
}

In loc de PlayerInfo puneti cum aveti voi. De ex P_Data... la `users` cum aveti voi tabelul in baza de date unde se salveaza conturile.

Acum, intram in baza de date. (localhost/phpmyadmin).

Screenshot_1.png.eb1fd981f4a4b247c75cb870e8913f13.png

 

Dupa ce ati intrat in baza de date apasati pe Structure.

Dupa aceea mai jos faceti o coloana.

Screenshot_3.png.712c5c2bba8205bcdd608d8ae1fc486c.png

 

Screenshot_4.thumb.png.d1e2cb2b235d5eb9b22ee7fb1a418eab.png

Ceva de genul trebuie sa arate coloana. Acum dam pe Save si suntem gata!

Sper ca celor incepatori le-a fost de ajutor. pa

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...

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. For more details you can also review our Terms of Use and Privacy Policy.