SA-MP Forums Archive
/me and /do - 2 lines - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: /me and /do - 2 lines (/showthread.php?tid=444439)



/me and /do - 2 lines - Iuly1234 - 16.06.2013

Hello SA-MP.COM

I want to make /do and /me command with two lines.

I try with THIS, but i falied.

Commands:

/me:
pawn Код:
CMD:me(playerid, params[])
{
    new string[128];
    if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
    if(sscanf(params, "s[128]", params)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /me [action]");
    if(AntiAdv(playerid, params)) return 1;
    format(string, sizeof(string), "* %s %s", RPN(playerid), params);
    SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
    return 1;
}
/do:

pawn Код:
CMD:do(playerid, params[])
{
    new string[128];
    if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
    if(sscanf(params, "s[128]", params)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /me [action]");
    if(AntiAdv(playerid, params)) return 1;
    format(string, sizeof(string), "* %s (( %s ))", params, RPN(playerid));
    SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
    return 1;
}
Sorry for my very bad english !!!

HELP PLEASE


Re: /me and /do - 2 lines - Scenario - 16.06.2013

There's no reason to check if a player is logged in on each command as you can do it with one of ZCMD's callbacks. Furthermore, you're dealing with a single string- there's no reason to use sscanf here.

You can't do it in two lines, but it's close enough! And remember, the amount of lines in a script really don't mean a damn thing.

pawn Код:
public OnPlayerCommandReceived(playerid, cmdtext[])
{
    if(!IsPlayerLoggedIn(playerid))
    {
        SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
        return 0;
    }
    return 1;
}

CMD:me(playerid, params[])
{
    if(AntiAdv(playerid, params[]))
        return 1;
    if(strlen(params) < 3) // if the "action" in the /me command was less than 3 characters in length, the command won't process
        return 1;
   
    new
        string[144];
   
    format(string, sizeof(string), "* %s %s", RPN(playerid), params);
    SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
    return 1;
}

CMD:do(playerid, params[])
{
    if(AntiAdv(playerid, params[]))
        return 1;
    if(strlen(params) < 3) // if the "description" in the /do command was less than 3 characters in length, the command won't process
        return 1;
   
    new
        string[144];
   
    format(string, sizeof(string), "* %s (( %s ))", params, RPN(playerid));
    SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
    return 1;
}
Try searching BEFORE posting next time, please.


Re: /me and /do - 2 lines - dannyk0ed - 16.06.2013

Here.
pawn Код:
SendCustomPlayerMessage(Float:radi, playerid, text[], col1, col2, col3, col4, col5)
{
    if(strlen(text) > 98)
    {
        new text1[99],
            text2[99],
            string[196];

        strmid(text2, text, 98, 196);
        strmid(text1, text, 0, 98);

        format(string, 196, "%s...", text1);
        ProxDetector(radi, playerid, string, col1, col2, col3, col4, col5);
       
        format(string, 196, "...%s", text2);
        ProxDetector(radi, playerid, string, col1, col2, col3, col4, col5);
    }
    else ProxDetector(radi, playerid, text, col1, col2, col3, col4, col5);
}
Add that and replace
pawn Код:
SendNearbyMessage
to
pawn Код:
SendCustomPlayerMessage



Re: /me and /do - 2 lines - Iuly1234 - 17.06.2013

Quote:
Originally Posted by dannyk0ed
Посмотреть сообщение
Here.
pawn Код:
SendCustomPlayerMessage(Float:radi, playerid, text[], col1, col2, col3, col4, col5)
{
    if(strlen(text) > 98)
    {
        new text1[99],
            text2[99],
            string[196];

        strmid(text2, text, 98, 196);
        strmid(text1, text, 0, 98);

        format(string, 196, "%s...", text1);
        ProxDetector(radi, playerid, string, col1, col2, col3, col4, col5);
       
        format(string, 196, "...%s", text2);
        ProxDetector(radi, playerid, string, col1, col2, col3, col4, col5);
    }
    else ProxDetector(radi, playerid, text, col1, col2, col3, col4, col5);
}
Add that and replace
pawn Код:
SendNearbyMessage
to
pawn Код:
SendCustomPlayerMessage
pawn Код:
stock SendCustomPlayerMessage(Float:radi, playerid, text[], col1, col2, col3, col4, col5)
{
    if(strlen(text) > 98)
    {
        new text1[99],
            text2[99],
            string[196];

        strmid(text2, text, 98, 196);
        strmid(text1, text, 0, 98);

        format(string, 196, "%s ...", text1);
        ProxDetector(radi, playerid, string, col1, col2, col3, col4, col5);

        format(string, 196, "... %s", text2);
        ProxDetector(radi, playerid, string, col1, col2, col3, col4, col5);
    }
    else ProxDetector(radi, playerid, text, col1, col2, col3, col4, col5);
}
pawn Код:
CMD:me(playerid, params[])
{
    new string[128];
    if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
    if(sscanf(params, "s[128]", params)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /me [action]");
    if(AntiAdv(playerid, params)) return 1;
    format(string, sizeof(string), "* %s %s", RPN(playerid), params);
    SendCustomPlayerMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
    return 1;
}
When i compile:

pawn Код:
C:\Users\Iuly\Desktop\Desk\Sictir RolePlay\gamemodes\ZRP.pwn(637) : error 017: undefined symbol "ProxDetector"
C:\Users\Iuly\Desktop\Desk\Sictir RolePlay\gamemodes\ZRP.pwn(640) : error 017: undefined symbol "ProxDetector"
C:\Users\Iuly\Desktop\Desk\Sictir RolePlay\gamemodes\ZRP.pwn(642) : error 017: undefined symbol "ProxDetector"
C:\Users\Iuly\Desktop\Desk\Sictir RolePlay\gamemodes\ZRP.pwn(625) : warning 203: symbol is never used: "col5"
C:\Users\Iuly\Desktop\Desk\Sictir RolePlay\gamemodes\ZRP.pwn(625) : warning 203: symbol is never used: "col4"
C:\Users\Iuly\Desktop\Desk\Sictir RolePlay\gamemodes\ZRP.pwn(625) : warning 203: symbol is never used: "col3"
C:\Users\Iuly\Desktop\Desk\Sictir RolePlay\gamemodes\ZRP.pwn(625) : warning 203: symbol is never used: "col2"
C:\Users\Iuly\Desktop\Desk\Sictir RolePlay\gamemodes\ZRP.pwn(625) : warning 203: symbol is never used: "col1"
C:\Users\Iuly\Desktop\Desk\Sictir RolePlay\gamemodes\ZRP.pwn(625) : warning 203: symbol is never used: "playerid"
C:\Users\Iuly\Desktop\Desk\Sictir RolePlay\gamemodes\ZRP.pwn(625) : warning 203: symbol is never used: "radi"
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


3 Errors.



Re: /me and /do - 2 lines - Pottus - 17.06.2013

Ok two lines.

pawn Код:
CMD:me(playerid, arg[]) { if(isnull(arg)) return SendClientMessageToAll(0xFF00FFFF, "Usage /me Does Some Action"); new line[128]; new name[MAX_PLAYER_NAME]; GetPlayerName(playerid, name, MAX_PLAYER_NAME); format(line, sizeof(line), "%s %s", name, arg); return SendClientMessageToAll(0xFF00FFFF, line); }
pawn Код:
CMD:do(playerid, arg[]) { if(isnull(arg)) return SendClientMessageToAll(0xFF00FFFF, "Usage /do Does Some Action"); new line[128]; new name[MAX_PLAYER_NAME]; GetPlayerName(playerid, name, MAX_PLAYER_NAME); format(line, sizeof(line), "%s %s", name, arg); return SendClientMessageToAll(0xFF00FFFF, line); }



Re: /me and /do - 2 lines - Iuly1234 - 17.06.2013

Help please?


Re: /me and /do - 2 lines - lean1337 - 17.06.2013

you need this aswell.


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);
                if(GetPlayerVirtualWorld(playerid) == GetPlayerVirtualWorld(i))
                {
                    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);
                    }
                }
            }
        }
    }
    return 1;
}



Re: /me and /do - 2 lines - Red_Dragon. - 18.06.2013

See my filterscript (link in the signature), it may help you. It's very simple in the type of coding as it uses ZCMD and without too much lines (which you may not understand), so I think you'll be able to understand it well.


Re: /me and /do - 2 lines - Iuly1234 - 18.06.2013

Quote:
Originally Posted by lean1337
Посмотреть сообщение
you need this aswell.


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);
                if(GetPlayerVirtualWorld(playerid) == GetPlayerVirtualWorld(i))
                {
                    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);
                    }
                }
            }
        }
    }
    return 1;
}
I add this but when I use /me command nothing happens


Re: /me and /do - 2 lines - Iuly1234 - 19.06.2013

Anyone please?