25.07.2012, 09:00
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.
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);
}
}
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;
}
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;
}
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;
}
format(str, sizeof(str), "* %s %s", str, cmdtext[4]);
ProxDetector(30.0,playerid,str,COLOR_WHITE);
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.
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;
}
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;
}