domingo, 3 de julho de 2011

Comando /Prender [id],/Soltar [id] e /darpolicial [id] (USADO POR ADMIN)



//Vou ensinar a fazer o comando de prender [id] para samp!
//Muitos acham que e dificil,mas e muito facil!

//No topo do seu GameMode

new policial[MAX_PLAYERS];

#define COLOR_RED 0x33AA33AA

//Primeiro,o comando de dar Policial,feito por Admin
//Em
public OnPlayerCommandText(playerid,cmdtext[]) {
    new index, cmd[128];
    cmd = strtok(cmdtext, index);
    if (!strcmp("/darpolicial",cmd,true,12)) {
if(IsPlayerAdmin(playerid))
{
        new tmp[128];
        tmp = strtok(cmdtext, index);
        if(!strlen(tmp)  || !IsNumeric(tmp)) {
            return SendClientMessage(playerid,COLOR_RED,"USE: /darpolicial [ID DO JOGADOR]");
        }
        else {
            new id=strval(tmp);
            if(!IsPlayerConnected(id)) {
                return SendClientMessage(playerid,COLOR_RED,"JOGADOR NAO CONECTADO");                 }
            else {
                policial[strval(tmp)] = 1;
SendClientMessage(playerid,COLOR_RED,"Admin te deu profissao de policial");
            }
        }
}
        return 1;
    }

//No final do Game Mode


//------------------------------
strtok(const string[], &index)
{
    new length = strlen(string);
    while ((index < length) && (string[index] <= ' '))
    {
        index++;
    }
    new offset = index;
    new result[20];
    while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
    {
        result[index - offset] = string[index];
        index++;
    }
    result[index - offset] = EOS;
    return result;
}
//-------------------------------
stock IsNumeric(const string[]) { // by DracoBlue
    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]!='+') // Not a number,'+' or '-'
        || (string[i]=='-' && i!=0)                                             // A '-' but not at first.
        || (string[i]=='+' && i!=0)                                             // A '+' but not at first.
        ) return false;
    }
    if (length==1 && (string[0]=='-' || string[0]=='+')) return false;
    return true;
}

//Agora,o comando de prender [id]

//Em
public OnPlayerCommandText(playerid,cmdtext[]) {
if (!strcmp("/prender",cmd,true,8)) {
        if(IsPlayerAdmin(playerid))
        {
        new tmp[128];
        tmp = strtok(cmdtext, index);
        if(!strlen(tmp)  || !IsNumeric(tmp)) {
return SendClientMessage(playerid,COLOR_RED,"USE: /prender [ID DO JOGADOR]");
        }
        else {
            new id=strval(tmp);
            if(!IsPlayerConnected(id)) {
                return SendClientMessage(playerid,COLOR_RED,"JOGADOR NAO CONECTADO");                 }
            else {
       SetPlayerPos(strval(tmp),264.4483,77.7306,1001.0391);
       SetPlayerInterior(strval(tmp),6);
       GameTextForPlayer(strval(tmp),"~r~ADMIN: ~g~Voce esta preso ate eu te soltar!!",5000,3);
            }
        }
        }

//e o comando de Soltar [id]

    if (!strcmp("/soltar",cmd,true,7)) {
if(IsPlayerAdmin(playerid))
{
        new tmp[128];
        tmp = strtok(cmdtext, index);
        if(!strlen(tmp)  || !IsNumeric(tmp)) {
            return SendClientMessage(playerid,COLOR_RED,"USE: /soltar [ID DO JOGADOR]");
        }
        else {
            new id=strval(tmp);
            if(!IsPlayerConnected(id)) {
                return SendClientMessage(playerid,COLOR_RED,"JOGADOR NAO CONECTADO");                 }
            else {
                SetPlayerInterior(strval(tmp),6);
                SetPlayerPos(strval(tmp),268.1906,77.8688,1001.0391);
            }
        }
        }



Um comentário:

  1. Cara Foi um bom tutorial mais quer aprender a criar um comando assim /prender [ id ] [Minutos ] como fasso?

    ResponderExcluir