Jump to content

Cerere Tutorial - /healall ( comanda admin)


razvan215

Recommended Posts

Salut,in acest post o sa iti arat cum pui restrictie pe o comanda...(healall ban etc..)

Este simplu pai,in primul rand ai restrictia IsPlayerConnected care verifica daca playerul este conectat avem o { (acoalada mai jos) apasam enter si punem:

if(PlayerInfo[playerid][pAdmin] >= 4)
{
//Restul de conditii..

Unde:

PlayerInfo - Aici la unele sunt PlayerInfo(de obicei pe INI,dar si pe MySQL am intalnit.Poate fi inloccuit cu PlayerData.

playerid  - O alta variabila pentru functia PlayerInfo(un singur player).

pAdmin - Verifica daca playerul care a tastat comanda este administrator.

>= - Aici daca gradul este mai mare sau egal cu 4.(gradul administratorului).

4 - Gradul adminului care poate folosi comanda este 4.

 

Exmplu comanda /healall:

if(strcmp(cmd, "/healall", true) == 0)
	{
	    GetPlayerName(playerid, sendername, sizeof(sendername));

	    if(IsPlayerConnected(playerid))
	    {
	        if(PlayerInfo[playerid][pAdmin] >= 4)
	        {
	            for(new i = 0; i < MAX_PLAYERS; i ++)
				{
				    if(IsPlayerConnected(i))
				    {
					    SetPlayerHealth(i, 99);
                                          format(string, sizeof(string), "Administratorul %s a dat tuturor playerilor full health.", sendername);
                                          SendClientMessageToAll(COLOR_LIGHTRED, string);
					}
				}
			}
			else
			{
			    SendClientMessage(playerid, COLOR_RED, ": Nu ai acces la aceasta comanda!");
			}
		}
		else
		{
		    SendClientMessage(playerid, COLOR_RED, ": Trebuie sa fii logat ca sa poti folosi aceasta comanda!");
		}
		return 1;
		}
Edited by Joe.

 

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • 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.