Making an /L command
#9

Here, hope it works for you!

pawn Код:
if(strcmp(cmd, "/local", true) == 0 || strcmp(cmd, "/l", true) == 0) == 0)
{
    if(IsPlayerConnected(playerid))
    {
        new str[160];
        GetPlayerName(playerid, str, MAX_PLAYER_NAME);
        new length = strlen(cmdtext);
        while ((idx < length) && (cmdtext[idx] <= ' '))
        {
            idx++;
        }
        new offset = idx;
        new result[200];
        while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
        {
            result[idx - offset] = cmdtext[idx];
            idx++;
        }
        result[idx - offset] = EOS;
        if(!strlen(result))
        {
            SendClientMessage(playerid, COLOR_GRAD2, "USAGE: (/l)ocal [local chat]");
            return 1;
        }
        format(string, sizeof(string), "%s Says: %s", str, result);
        ProxDetector(20.0, playerid, string,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
        printf("%s", string);
    }
    return 1;
}
Function if you don't have ProxDetector already.
pawn Код:
forward ProxDetector(Float:radi, playerid, string[],col1,col2,col3,col4,col5);
public ProxDetector(Float:radi, playerid, string[],col1,col2,col3,col4,col5)
{
    if(IsPlayerConnected(playerid))
    {
        new Float:posx, Float:posy, Float:posz;
        new Float:oldposx, Float:oldposy, Float:oldposz;
        new Float:tempposx, Float:tempposy, Float:tempposz;
        GetPlayerPos(playerid, oldposx, oldposy, oldposz);
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
            if(IsPlayerConnected(i))
            {
                GetPlayerPos(i, posx, posy, posz);
                tempposx = (oldposx -posx);
                tempposy = (oldposy -posy);
                tempposz = (oldposz -posz);
                new playerworld, player2world;
                playerworld = GetPlayerVirtualWorld(playerid);
                player2world = GetPlayerVirtualWorld(i);
                if(playerworld == player2world)
                {
                    if (((tempposx < radi/16) && (tempposx > -radi/16)) && ((tempposy < radi/16) && (tempposy > -radi/16)) && ((tempposz < radi/16) && (tempposz > -radi/16)))
                    {
                        SendClientMessage(i, col1, string);
                    }
                    else if (((tempposx < radi/8) && (tempposx > -radi/8)) && ((tempposy < radi/8) && (tempposy > -radi/8)) && ((tempposz < radi/8) && (tempposz > -radi/8)))
                    {
                        SendClientMessage(i, col2, string);
                    }
                    else if (((tempposx < radi/4) && (tempposx > -radi/4)) && ((tempposy < radi/4) && (tempposy > -radi/4)) && ((tempposz < radi/4) && (tempposz > -radi/4)))
                    {
                        SendClientMessage(i, col3, string);
                    }
                    else if (((tempposx < radi/2) && (tempposx > -radi/2)) && ((tempposy < radi/2) && (tempposy > -radi/2)) && ((tempposz < radi/2) && (tempposz > -radi/2)))
                    {
                        SendClientMessage(i, col4, string);
                    }
                    else if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
                    {
                        SendClientMessage(i, col5, string);
                    }
                }
            }
            else
            {
                SendClientMessage(i, col1, string);
            }
        }
    }
    return 1;
}
Reply


Messages In This Thread
Making an /L command - by iPoisonxL - 03.07.2013, 15:42
Re: Making an /L command - by iPoisonxL - 03.07.2013, 16:10
Re: Making an /L command - by TheStreetsRP - 03.07.2013, 16:11
Re: Making an /L command - by introzen - 03.07.2013, 16:12
Re: Making an /L command - by iPoisonxL - 03.07.2013, 16:22
Re: Making an /L command - by Anak - 03.07.2013, 17:06
Re: Making an /L command - by iPoisonxL - 03.07.2013, 17:11
Re: Making an /L command - by Antonio144 - 03.07.2013, 17:21
Re: Making an /L command - by tony_fitto - 03.07.2013, 17:28
Re: Making an /L command - by iPoisonxL - 04.07.2013, 10:25

Forum Jump:


Users browsing this thread: 1 Guest(s)