Zdravim mam na serveru napawnen prikazy napriklad /ban id duvod normal hrace zabanuje ale kdyz nekdo da /ban a mezeru tak server spadne jakto ??
[list]#include
#include
#include
#include dudb_mod
#define QCMD:%1(%2) \
forward cmd_%1(%2); \
public cmd_%1(%2)
#define SCM SendClientMessage
#define SCMTA SendClientMessageToAll
#define COLOR_WHITE 0xFFFFFFAA
#define COLOR_GREY 0xAFAFAFAA
#define COLOR_SYSTEM 0xAFAFAFAA
#define COLOR_BLACK 0x000000AA
#define COLOR_BROWN 0xA52A2AAA
#define COLOR_ADMIN 0x2587CEFF
#define COLOR_YELLOW 0xB8860BAA
#define COLOR_BLUE 0x00FFFF
#define COLOR_GREEN 0x33AA33AA
#define COLOR_PINK 0xFFC0CBAA
#define COLOR_RED 0xE10000AA
#define BARVA_OLIVOVA 0x9ACD32AA
#define BARVA_FIALOVA 0x800080AA
#define COLOR_ORANGE 0xFF9900AA
#define BARVA_SVETLEMODRA 0x33CCFFAA
#define BARVA_TMAVEZELENA 0x008000FF
#define BARVA_SVETLEZELENA 0x7FFF00AA
#undef MAX_PLAYERS
#define MAX_PLAYERS 100 // nastavte si podle slotů na serveru / změň číslo '100'
stock PlayerName(playerid)
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
return name;
}
new Alvl[MAX_PLAYERS];
stock Warp(playerid,Float:x,Float:y,Float:z)
{
if(IsPlayerInAnyVehicle(playerid))
{
new brmbrm = GetPlayerVehicleID(playerid);
SetVehiclePos(brmbrm,x,y,z);
}
else
{
SetPlayerPos(playerid,x,y,z);
}
return true;
}
stock ZakazanaZbran(playerid) // upravte si zakázané zbraně
{
new zbran = GetPlayerWeapon(playerid);
return false;
}
stock sscanf(string[], format[], {Float,_}:...) // by Y_less
{
#if defined isnull
if (isnull(string))
#else
if (string[0] == 0 || (string[0] == 1 && string[1] == 0))
#endif
{
return format[0];
}
#pragma tabsize 4
new
formatPos = 0,
stringPos = 0,
paramPos = 2,
paramCount = numargs(),
delim = ' ';
while (string[stringPos] && string[stringPos] <= ' ')
{
stringPos++;
}
while (paramPos < paramCount && string[stringPos])
{
switch (format[formatPos++])
{
case '\0':
{
return 0;
}
case 'i', 'd':
{
new
neg = 1,
num = 0,
ch = string[stringPos];
if (ch == '-')
{
neg = -1;
ch = string[++stringPos];
}
do
{
stringPos++;
if ('0' <= ch <= '9')
{
num = (num * 10) + (ch - '0');
}
else
{
return -1;
}
}
while ((ch = string[stringPos]) > ' ' && ch != delim);
setarg(paramPos, 0, num * neg);
}
case 'h', 'x':
{
new
num = 0,
ch = string[stringPos];
do
{
stringPos++;
switch (ch)
{
case 'x', 'X':
{
num = 0;
continue;
}
case '0' .. '9':
{
num = (num << 4) | (ch - '0');
}
case 'a' .. 'f':
{
num = (num << 4) | (ch - ('a' - 10));
}
case 'A' .. 'F':
{
num = (num << 4) | (ch - ('A' - 10));
}
default:
{
return -1;
}
}
}
while ((ch = string[stringPos]) > ' ' && ch != delim);
setarg(paramPos, 0, num);
}
case 'c':
{
setarg(paramPos, 0, string[stringPos++]);
}
case 'f':
{
new changestr[16], changepos = 0, strpos = stringPos;
while(changepos < 16 && string[strpos] && string[strpos] != delim)
{
changestr[changepos++] = string[strpos++];
}
changestr[changepos] = '\0';
setarg(paramPos,0,_:floatstr(changestr));
}
case 'p':
{
delim = format[formatPos++];
continue;
}
case '\'':
{
new
end = formatPos - 1,
ch;
while ((ch = format[++end]) && ch != '\'') {}
if (!ch)
{
return -1;
}
format[end] = '\0';
if ((ch = strfind(string, format[formatPos], false, stringPos)) == -1)
{
if (format[end + 1])
{
return -1;
}
return 0;
}
format[end] = '\'';
stringPos = ch + (end - formatPos);
formatPos = end + 1;
}
case 'u':
{
new
end = stringPos - 1,
id = 0,
bool:num = true,
ch;
while ((ch = string[++end]) && ch != delim)
{
if (num)
{
if ('0' <= ch <= '9')
{
id = (id * 10) + (ch - '0');
}
else
{
num = false;
}
}
}
if (num && IsPlayerConnected(id))
{
setarg(paramPos, 0, id);
}
else
{
#if !defined foreach
#define foreach(%1,%2) for (new %2 = 0; %2 < MAX_PLAYERS; %2++) if (IsPlayerConnected(%2))
#define __SSCANF_FOREACH__
#endif
string[end] = '\0';
num = false;
new
name[MAX_PLAYER_NAME];
id = end - stringPos;
foreach (Player, playerid)
{
GetPlayerName(playerid, name, sizeof (name));
if (!strcmp(name, string[stringPos], true, id))
{
setarg(paramPos, 0, playerid);
num = true;
break;
}
}
if (!num)
{
setarg(paramPos, 0, INVALID_PLAYER_ID);
}
string[end] = ch;
#if defined __SSCANF_FOREACH__
#undef foreach
#undef __SSCANF_FOREACH__
#endif
}
stringPos = end;
}
case 's', 'z':
{
new
i = 0,
ch;
if (format[formatPos])
{
while ((ch = string[stringPos++]) && ch != delim)
{
setarg(paramPos, i++, ch);
}
if (!i)
{
return -1;
}
}
else
{
while ((ch = string[stringPos++]))
{
setarg(paramPos, i++, ch);
}
}
stringPos--;
setarg(paramPos, i, '\0');
}
default:
{
continue;
}
}
while (string[stringPos] && string[stringPos] != delim && string[stringPos] > ' ')
{
stringPos++;
}
while (string[stringPos] && (string[stringPos] == delim || string[stringPos] <= ' '))
{
stringPos++;
}
paramPos++;
}
do
{
if ((delim = format[formatPos++]) > ' ')
{
if (delim == '\'')
{
while ((delim = format[formatPos++]) && delim != '\'') {}
}
else if (delim != 'z')
{
return delim;
}
}
}
while (delim > ' ');
return 0;
}
stock IsNumeric(const string[])
{
new length=strlen(string);
if (length==0) return false;
for (new i = 0; i < length; i++)
{
if ((string[i] > '9' || string[i] < '0' && string[i]!='-' && string[i]!='+')|| (string[i]=='-' && i!=0)|| (string[i]=='+' && i!=0)) return false;
}
if (length==1 && (string[0]=='-' || string[0]=='+')) return false;
return true;
}
public OnPlayerCommand(playerid,command[])
{
new
cmd[50],
params[128],
size = strfind(command, " ", true);
if(size != -1)
{
strmid(params,command,size+1,strlen(command));
strmid(cmd,command,1,size);
}else
{
strmid(cmd,command,1,strlen(command));
params = " ";
}
format(cmd,50,"cmd_%s",cmd);
if(CallLocalFunction(cmd,"is",playerid,params))
{
return true;
}
}
public OnPlayerConnect(playerid)
{
Alvl[playerid] = 0;
return 1;
}
public OnPlayerCommandText(playerid,cmdtext[]){
if(strlen(cmdtext) > 0)
{
Alvl[playerid] = dUserINT(PlayerName(playerid)).("adminlvl");
}
return OnPlayerCommand(playerid,cmdtext);
}
QCMD:ban(playerid,params[])
{
if(Alvl[playerid] >= 1)
{
new
id = strval(params),
duvod[25],
string[128];
if(sscanf(params,"uz",id,duvod)) return SCM(playerid,COLOR_ORANGE,"Použizí: /ban [iD] [DŮVOD]");
else if(!IsPlayerConnected(id)) return SCM(playerid,COLOR_ORANGE,"[ ! ] Hráč není na serveru!");
else if(Alvl[id]>=1) return SCM(playerid,COLOR_RED,"Nemůžeš zabanovat administrátora");
else
format(string,sizeof(string),"Administrátor %s zabanoval hráče %s z důvodu %s",PlayerName(playerid),PlayerName(id),duvod);
SCMTA(COLOR_RED,string);
BanEx(id,duvod);
}else SCM(playerid,COLOR_ORANGE,"Nemáš dostatečný admin práva");
return true;
}[/list]