/ban help
#5

pawn Код:
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;
}
I hope that helped a bit lol
Reply


Messages In This Thread
/ban help - by YungGee - 21.01.2011, 08:54
Re: /ban help - by Alby Fire - 21.01.2011, 08:58
Re: /ban help - by Sascha - 21.01.2011, 08:58
Re: /ban help - by YungGee - 21.01.2011, 09:00
Re: /ban help - by Sascha - 21.01.2011, 09:05
Re: /ban help - by YungGee - 21.01.2011, 09:11
Re: /ban help - by HyperZ - 21.01.2011, 09:28

Forum Jump:


Users browsing this thread: 1 Guest(s)