[Help] RP commands /me /do
#4

My eyes hurts when I see commands like that. This is an optional way using sscanf and ZCMD.

pawn Code:
COMMAND:me(playerid, params[])
{
    new text[128], string[128];
    if(sscanf(params, "s[127]", text)) return SendClientMessage(playerid, 0xFFFFFFAA, "USAGE: /me [action]");
    format(string, sizeof(string), "** %s %s", RemoveUnderScore(playerid), text);
    NewProx(playerid, 0xC688D4AA, string, 30.0);
    return 1;
}
COMMAND:do(playerid, params[])
{
    new text[128], string[128];
    if(sscanf(params, "s[127]", text)) return SendClientMessage(playerid, 0xFFFFFFAA, "USAGE: /do [action]");
    format(string, sizeof(string), "** %s (( %s ))", text, RemoveUnderScore(playerid));
    NewProx(playerid, 0xC688D4AA, string, 30.0);
    return 1;
}
// This is used to send the message only to nearby players.
stock NewProx(playerid, color, string[], Float:radi)
{
    new Float:pposx, Float:pposy, Float:pposz;
    new Float:oldpposx, Float:oldpposy, Float:oldpposz;
    new Float:temppposx, Float:temppposy, Float:temppposz;
       
    GetPlayerPos(playerid, oldpposx, oldpposy, oldpposz);
       
    for(new i = 0; i < MAX_PLAYERS; i++)
        {
            if(IsPlayerConnected(i) && (GetPlayerVirtualWorld(playerid) == GetPlayerVirtualWorld(i)))
            {
                GetPlayerPos(i, pposx, pposy, pposz);
                temppposx = (oldpposx -pposx);
                temppposy = (oldpposy -pposy);
                temppposz = (oldpposz -pposz);
                if (((temppposx < radi) && (temppposx > -radi)) && ((temppposy < radi) && (temppposy > -radi)) && ((temppposz < radi) && (temppposz > -radi)))
                {
                    SendClientMessage(i, color, string);
                }
            }
        }
    return 1;
}
// This will save you a lot of code, formats a "rp name" out of a playerid.
stock RemoveUnderScore(playerid)
{
    new namewithoutunderscorename[MAX_PLAYER_NAME];
    GetPlayerName(playerid,namewithoutunderscorename,sizeof(namewithoutunderscorename));
    for(new i = 0; i < MAX_PLAYER_NAME; i++)
    {
        if(namewithoutunderscorename[i] == '_') namewithoutunderscorename[i] = ' ';
    }
    return namewithoutunderscorename;
}
Reply


Messages In This Thread
[Help] RP commands /me /do - by dovys11 - 24.06.2010, 08:33
Re: [Help] RP commands /me /do - by TouR - 24.06.2010, 08:36
Re : [Help] RP commands /me /do - by Amine_Mejrhirrou - 23.01.2011, 15:03
Re: [Help] RP commands /me /do - by Not available - 23.01.2011, 15:06
Re : [Help] RP commands /me /do - by Amine_Mejrhirrou - 23.01.2011, 19:55
Re: [Help] RP commands /me /do - by Elviss - 23.01.2011, 20:04
Re: [Help] RP commands /me /do - by bestr32 - 03.04.2011, 17:26
Re: [Help] RP commands /me /do - by bestr32 - 03.04.2011, 17:28
Re: [Help] RP commands /me /do - by Luis- - 03.04.2011, 17:29
Re: [Help] RP commands /me /do - by Mean - 03.04.2011, 17:34

Forum Jump:


Users browsing this thread: 1 Guest(s)