dcmd_ban(playerid,params[])
{
new id, name[MAX_PLAYER_NAME],on[MAX_PLAYER_NAME];
new tmp[256], Index, str[49];
tmp = strtok(params,Index), id = strval(tmp);
GetPlayerName(id,on,sizeof(on));
GetPlayerName(playerid,name,sizeof(name));
if(pInfo[playerid][Level] < 3) return SendClientMessage(playerid,RED,">> You Need To Be Level 3+ To Use This Command!");
if(!strlen(params)) return SendClientMessage(playerid,RED,"USAGE: /ban [id] ");
if(!IsPlayerConnected(id)) return SendClientMessage(playerid,RED,">> Invalid [id]!");
format(str,sizeof(str),">> Administrator %s Has Banned %s From The Server!",name,on);
SendClientMessageToAll(RED,str);
Ban(id);
return 1;
}
dcmd_ban(playerid,params[])
{
new id, name[MAX_PLAYER_NAME],on[MAX_PLAYER_NAME];
new tmp[256], Index, str[49];
tmp = strrest(params,idx);
id = strval(tmp);
GetPlayerName(id,on,sizeof(on));
GetPlayerName(playerid,name,sizeof(name));
if(pInfo[playerid][Level] < 3) return SendClientMessage(playerid,RED,">> You Need To Be Level 3+ To Use This Command!");
if(!strlen(params)) return SendClientMessage(playerid,RED,"USAGE: /ban [id] [reason]");
if(!IsPlayerConnected(id)) return SendClientMessage(playerid,RED,">> Invalid [id]!");
format(str,sizeof(str),">> Administrator %s Has Banned %s Reason: %s",name,on,tmp);
SendClientMessageToAll(RED,str);
Ban(id);
return 1;
}
stock strrest(const string[], index)
{
new length = strlen(string),offset = index,result[256];
while ((index < length) && ((index - offset) < (sizeof(result) - 1)) && (string[index] > '\r'))
{
result[index - offset] = string[index];
index++;
}
result[index - offset] = EOS;
return result;
}
dcmd_ban(playerid,params[])
{
new id, name[MAX_PLAYER_NAME],on[MAX_PLAYER_NAME];
new tmp[256], Index, str[49];
tmp = strtok(params,Index), id = strval(tmp);
GetPlayerName(id,on,sizeof(on));
GetPlayerName(playerid,name,sizeof(name));
if(pInfo[playerid][Level] < 3) return SendClientMessage(playerid,RED,">> You Need To Be Level 3+ To Use This Command!");
if(!strlen(params)) return SendClientMessage(playerid,RED,"USAGE: /ban [id] ");
if(!IsPlayerConnected(id)) return SendClientMessage(playerid,RED,">> Invalid [id]!");
tmp = strrest(params, idx);
if(!strlen(tmp)) return SendClientMessage(playerid, RED, "/USEAGE: /ban [id] [reason]");
format(str,sizeof(str),">> Administrator %s Has Banned %s From The Server! (%s)",name,on, tmp);
SendClientMessageToAll(RED,str);
Ban(id);
return 1;
}
stock strrest(const string[], index)
{
new length = strlen(string),offset = index,result[256];
while ((index < length) && ((index - offset) < (sizeof(result) - 1)) && (string[index] > '\r'))
{
result[index - offset] = string[index];
index++;
}
result[index - offset] = EOS;
return result;
}
dcmd_ban(playerid,params[])
{
new id, name[MAX_PLAYER_NAME],on[MAX_PLAYER_NAME];
new tmp[256], Index, str[49];
tmp = strtok(params,Index), id = strval(tmp); //gets the id of the player so the first characters that are behind each other without a space between and converts it into an integer
GetPlayerName(id,on,sizeof(on));
GetPlayerName(playerid,name,sizeof(name));
if(pInfo[playerid][Level] < 3) return SendClientMessage(playerid,RED,">> You Need To Be Level 3+ To Use This Command!");
if(!strlen(params)) return SendClientMessage(playerid,RED,"USAGE: /ban [id] ");
if(!IsPlayerConnected(id)) return SendClientMessage(playerid,RED,">> Invalid [id]!");
tmp = strrest(params, idx); //this gets the rest of the string, excluded the id... e.g. if you enter "/ban 10 you are a fool", it gets the "you are a fool"
if(!strlen(tmp)) return SendClientMessage(playerid, RED, "/USEAGE: /ban [id] [reason]"); //if there is no reason it sends this message
format(str,sizeof(str),">> Administrator %s Has Banned %s From The Server! (%s)",name,on, tmp); //the %s and the tmp include the reason into the string
SendClientMessageToAll(RED,str);
Ban(id);
return 1;
}
stock strrest(const string[], index) //this is the code you need to get the "rest" of a string which is not used by a strtok or so before
{
new length = strlen(string),offset = index,result[256];
while ((index < length) && ((index - offset) < (sizeof(result) - 1)) && (string[index] > '\r'))
{
result[index - offset] = string[index];
index++;
}
result[index - offset] = EOS;
return result;
}
error 017: undefined symbol "idx"
Briefly XD...Ahh could u explain how to do it in sccanf xD i sorta found the "uz" s**t a bit easier to understand xD
EDIT: with the code Код:
error 017: undefined symbol "idx" |
new idx;