SA-MP Forums Archive
I need help - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: I need help (/showthread.php?tid=93585)



I need help - pablodc - 25.08.2009


This is my question when the server using the command''/me''nothing happens''/me smoke'' nothing happens D:

Whats the error?


Quote:

if (strcmp(cmd, "/me", true) == 0) {
new string[120];
new player[24];
GetPlayerName(playerid,player,24);
if(!strlen(cmdtext))
{
SendClientMessage(playerid,COLOR_GREY,"Usage: /me [action]");
return 1;
}
format(string,sizeof(string),"%s %s",player,cmdtext[0]);
for(new i=0; i<MAX_PLAYERS; i++) if(IsPlayerConnected(i)) if(GetDistanceBetweenPlayers(playerid,i) <= 30 && i!=playerid)
{
SendClientMessage(i,COLOR_PURPLE,string);
SendClientMessage(playerid,COLOR_PURPLE,string);
return 1;
}
return 1;
}




Re: I need help - Joe Staff - 25.08.2009

Your use of the 'strcmp' function is incorrect for what you'retrying to achieve.
pawn Код:
if(!strcmp,cmdtext[1],"me",true,2))
That's better.

Also, on the line with the format, change "cmdtext[0]" to "cmdtext[4]"
remove the "&& i!=playerid" from your 'if' statement
and last but not least, remove the "SendClientMessage(playerid,COLOR_PURPLE,strin g);" line.


Re: I need help - The_Tough - 25.08.2009

wrong post .


Re: I need help - Memoryz - 25.08.2009

Here,

You can use mine:

pawn Код:
if(strcmp(cmd, "/me", true) == 0)
    {
        GetPlayerName(playerid, sendername, sizeof(sendername));
        new length = strlen(cmdtext);
        while ((idx < length) && (cmdtext[idx] <= ' '))
            {
                idx++;
            }
        new offset = idx;
        new result[64];
        while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
            {
                result[idx - offset] = cmdtext[idx];
                idx++;
            }
        result[idx - offset] = EOS;
        if(!strlen(result))
            {
                SendClientMessage(playerid, red, "USAGE: /me [action]");
                return 1;
            }
            else
            {
                format(string, sizeof(string), "* %s %s", sendername, result);
            }
        ProxDetector(30.0, playerid, string, red,red,red,red,red);
        printf("%s", string);
        return 1;
        }



Re: I need help - XtremeChio - 25.08.2009

Or you can use this one from wiki lol

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



Re: I need help - pablodc - 25.08.2009

Quote:

C:\Users\Pablo\Desktop\Sona GM\gamemodes\Sona.pwn(1111) : error 076: syntax error in the expression, or invalid function call
C:\Users\Pablo\Desktop\Sona GM\gamemodes\Sona.pwn(1111) : error 029: invalid expression, assumed zero
C:\Users\Pablo\Desktop\Sona GM\gamemodes\Sona.pwn(1135) : warning 225: unreachable code
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


2 Errors.

Quote:

if(!strcmp,cmdtext[1],"me",true,2)) {
new string[120];
new player[24];
GetPlayerName(playerid,player,24);
if(!strlen(cmdtext))
{
SendClientMessage(playerid,COLOR_GREY,"Usage: /me [action]");
return 1;
}
format(string,sizeof(string),"%s %s",player,cmdtext[4]);
for(new i=0; i<MAX_PLAYERS; i++) if(IsPlayerConnected(i)) if(GetDistanceBetweenPlayers(playerid,i) <= 30 )
{
SendClientMessage(i,COLOR_PURPLE,string);
return 1;
}
return 1;
}




Re: I need help - speedruntrainer - 25.08.2009

Quote:
Originally Posted by XtremeChio
Or you can use this one from wiki lol

pawn Код:
if(!strcmp(cmdtext, "/me", true, 3)) // 3 is the length of /me
  {
    if(cmdtext[3] == 0) {
      SendClientMessage(playerid, 0xFF0000FF, "USAGE: /me [action]");
      return 1;
    }
    new str[128];
    GetPlayerName(playerid, str, sizeof(str));
    format(str, sizeof(str), "* %s %s", str, cmdtext[4]);
    SendClientMessageToAll(0xFFFF00AA, str);
    return 1;
  }
Try that. And look at the times posted lol
It seems you have scripted 1000+ lines. But still hope it works.


Re: I need help - pablodc - 25.08.2009

Found thx all