Jump to content
  • 0

pomoc Admin Level


Stellet

Dotaz

Ahoj dělám vlasntí mod, ale něják mi blbne Admin System, chci aby to mohl level 1+ ale může to každý:

 

CMD:avezeni(playerid,params[])
{
new string[500];
new Pname[MAX_PLAYER_NAME];
GetPlayerName(playerid,Pname,sizeof(Pname));
format(string,sizeof(string),"/Players/%s.ini",Pname);
new id,cas,str[128];
if(Hrac[playerid][AdminLevel] < 0) return SendClientMessage(playerid,COLOR_WHITE,"Tento příkaz neexistuje!");
{
  if(sscanf(params,"uis",id,cas,params)) return SendClientMessage(playerid,COLOR_WHITE,"Použití: /avezeni id cas důvod");
{
   new Name[64];
   GetPlayerName(playerid,Name,64);
   new Name1[64];
   GetPlayerName(id,Name1,64);
if(!IsPlayerConnected(id)) return SendClientMessage(playerid,COLOR_WHITE,"Hráč se zadaným id není na serveru.");
else if(ajail[id] == 1) return SendClientMessage(playerid,COLOR_WHITE,"Hráč se zadaným id už je ve vězení.");
format(str,sizeof(str),"Administrátor %s uvěznil hráče %s do Admin Vězení na %i minut [Důvod: %s]",Name,Name1,cas,params);
SendClientMessageToAll(COLOR_RED,str);
ajail[id] = 1;
SetPlayerPos(id, -1790.7722,567.2419,333.3382);
prisonTime[id] = cas;
}
}
return 1;
}
Link to comment
Share on other sites

12 odpovědí na tuto otázku

Recommended Posts

  • 0

if(Hrac[playerid][AdminLevel] < 0) return SendClientMessage(playerid,COLOR_WHITE,"Tento příkaz neexistuje!");
else if(sscanf(params,"uis",id,cas,params)) return SendClientMessage(playerid,COLOR_WHITE,"Použití: /avezeni id cas důvod");
else

{

kod

}

Link to comment
Share on other sites

  • 0

Takže takto ?

 

CMD:avezeni(playerid,params[])
{
new string[500];
new Pname[MAX_PLAYER_NAME];
GetPlayerName(playerid,Pname,sizeof(Pname));
format(string,sizeof(string),"/Players/%s.ini",Pname);
new id,cas,str[128];
if(Hrac[playerid][AdminLevel] < 0) return SendClientMessage(playerid,COLOR_WHITE,"Tento příkaz neexistuje!");
else if(sscanf(params,"uis",id,cas,params)) return SendClientMessage(playerid,COLOR_WHITE,"Použití: /avezeni id cas důvod");
else if(!IsPlayerConnected(id)) return SendClientMessage(playerid,COLOR_WHITE,"Hráč se zadaným id není na serveru.");
else if(ajail[id] == 1) return SendClientMessage(playerid,COLOR_WHITE,"Hráč se zadaným id už je ve vězení.");
else
{
new Name[64];
  GetPlayerName(playerid,Name,64);
  new Name1[64];
   GetPlayerName(id,Name1,64);
format(str,sizeof(str),"Administrátor %s uvěznil hráče %s do Admin Vězení na %i minut [Důvod: %s]",Name,Name1,cas,params);
SendClientMessageToAll(COLOR_RED,str);
ajail[id] = 1;
SetPlayerPos(id, -1790.7722,567.2419,333.3382);
prisonTime[id] = cas;
}
return 1;
}
Link to comment
Share on other sites

  • 0

Jo a hlavně v té podmínce musíš mít toto:

if(Hrac[playerid][AdminLevel] < 1) return SendClientMessage(playerid,COLOR_WHITE,"Tento příkaz neexistuje!");

ty si tam měl nulu, což je špatně... Protože nikdo nemá menší admin level, jak nula, leda, že by si každému hráči nastavil hodnotu na -1. :d

Jinak ten způsob, jak si to měl předtím by měl taky jet, akorát tohle mně přijde přehlednější. :d

Edited by D@ndys
Link to comment
Share on other sites

  • 0

Aha :d Takže když budu chtít Admin Level větší jak 1 tak dám

if(Hrac[playerid][AdminLevel]  > 1) return SendClientMessage(playerid,COLOR_WHITE,"Tento příkaz neexistuje!");
žejo ?
Link to comment
Share on other sites

  • 0

ano, ale to potom příkaz nepůjde použít administrátorům, kteří mají level větší jak 1 (takže 2,3,4,5,6,...), což je svým způsobem blbost, protože čím větší level, tím větší možnosti by měl mít. :d Ale můžeš to mít obráceně, kdo ví... :d

Link to comment
Share on other sites

  • 0

jak jsem psal před tím:

if(Hrac[playerid][AdminLevel] < 1) return SendClientMessage(playerid,COLOR_WHITE,"Tento příkaz neexistuje!");

Vysvětlení: Pokud má hráč admin level menší jak 1 (zahrnuje čísla: 0, -1, -2, -3, -4, ...) odešle se return SCM.

Link to comment
Share on other sites

  • 0

ano můžeš. :d, ale nesmíš tam dávat return. Jinak by to psalo "Příkaz neexistuje" administrátorům, kteří mají lvl větší jak 0 (1,2,3,4,5,...)

a vypadalo by to asi takhle:

if (podminka) return SCM;
else if (podminka) retrun SCM;
else if (podminka) return SCM;

if (adminlvl > 0)
{
kod
}

Ale pokud takhle využíváš podmínky s returnama a jde to, tak je lepší si tak udělat všechny (pomocí těch returnů), mně to potom připadá jako čistší kód.

Link to comment
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
×
×
  • Create New...