strcmp /me command with radius
#1

Could someone please give me a strcmp /me command with a radius. I don't want ZCMD etc because it'll conflict with the rest of my script. I have searched all over and can't seem to find one which works. Thanks.
Reply
#2

Use ProxDetector.
Plus zcmd is faster than strcmp.
strcmp is old.
Reply
#3

pawn Код:
stock ProxDetector(Float:radi, playerid, string[],color)
{
    new Float:x,Float:y,Float:z;
    GetPlayerPos(playerid,x,y,z);
    foreach(Player,i)
    {
        if(!IsPlayerConnected(i))continue;
        if(IsPlayerInRangeOfPoint(i,radi,x,y,z)) SendClientMessage(i,color,string);
    }
}
pawn Код:
if(!strcmp(cmdtext, "/me", true, 3))
    {
        if(!cmdtext[3])return SendClientMessage(playerid, 0xFF0000FF, "USAGE: /me [action]");
        new str[128];
        GetPlayerName(playerid, str, sizeof(str));
        format(str, sizeof(str), "* %s %s", str, cmdtext[4]);
        ProxDetector(30.0,playerid,str,COLOR_WHITE);
        return 1;
    }
here you go

and, i agree with romel, ZCMD/YCMD is faster and newer
Reply
#4

I'm very tired and haven't learned zcmd so no...

Could you help me implement ProxDetector into this?

pawn Код:
if(!strcmp(cmdtext, "/me", true, 3)) // 3 is the length of /me
    {
        if(!cmdtext[3])return SendClientMessage(playerid, 0xFF0000FF, "USAGE: /me [action]");
        new str[128];
        GetPlayerName(playerid, str, sizeof(str));
        format(str, sizeof(str), "* %s %s", str, cmdtext[4]);
        SendClientMessageToAll(0xFFFF00AA, str);
        return 1;
    }
Reply
#5

pawn Код:
if(!strcmp(cmdtext, "/me", true, 3)) // 3 is the length of /me
    {
        if(!cmdtext[3])return SendClientMessage(playerid, 0xFF0000FF, "USAGE: /me [action]");
        new str[128];
        GetPlayerName(playerid, str, sizeof(str));
        GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
        new Float:Pos[3];
        format(str, sizeof(str), "* %s %s", str, cmdtext[4]);
        for(new i; i < MAX_PLAYERS; i++)
        {
            // 5 is the range
            if(IsPlayerInRangeOfPoint(i, Pos[0], Pos[1], Pos[2], 5))
                SendClientMessage(i, str, 0xFFFF00AA);
        }
        return 1;
    }
Reply
#6

I did that for you lol, check my post again, it was implemeted
pawn Код:
format(str, sizeof(str), "* %s %s", str, cmdtext[4]);
        ProxDetector(30.0,playerid,str,COLOR_WHITE);
Reply
#7

I saw that but it wouldn't work and I can't remember how I fixed it, haha.
Reply
#8

p.s
Код:
C:\Users\System user\Desktop\San Andreas\samp03e_svr_win32\gamemodes\Roleplay.pwn(515) : error 017: undefined symbol "Pos"
C:\Users\System user\Desktop\San Andreas\samp03e_svr_win32\gamemodes\Roleplay.pwn(515) : warning 215: expression has no effect
C:\Users\System user\Desktop\San Andreas\samp03e_svr_win32\gamemodes\Roleplay.pwn(515) : error 001: expected token: ";", but found "]"
C:\Users\System user\Desktop\San Andreas\samp03e_svr_win32\gamemodes\Roleplay.pwn(515) : error 029: invalid expression, assumed zero
C:\Users\System user\Desktop\San Andreas\samp03e_svr_win32\gamemodes\Roleplay.pwn(515) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
Reply
#9

Ok, use this one, it's right out of my gamemode, tested and works:
pawn Код:
if(!strcmp(cmdtext, "/me", true, 3)) // 3 is the length of /me
    {
        if(!cmdtext[3])return SendClientMessage(playerid, 0xFF0000FF, "USAGE: /me [action]");
        new str[128];
        GetPlayerName(playerid, str, sizeof(str));
        format(str, sizeof(str), "* %s %s", str, cmdtext[4]);
        ProxDetector(30.0, playerid, str, COLOR_PINK,COLOR_PINK,COLOR_PINK,COLOR_PINK,COLOR_PINK);
        return 1;
}
and the proxdetector:
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);
        //radi = 2.0; //Trigger Radius
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
            if(IsPlayerConnected(i) && (GetPlayerVirtualWorld(playerid) == GetPlayerVirtualWorld(i)))
            {

                    GetPlayerPos(i, posx, posy, posz);
                    tempposx = (oldposx -posx);
                    tempposy = (oldposy -posy);
                    tempposz = (oldposz -posz);
                    //printf("DEBUG: X:%f Y:%f Z:%f",posx,posy,posz);
                    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);
                    }
                }

            }
        }
    //not connected
    return 1;
}
this one works, i use it myself
Reply
#10

Thank you very much
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)