SendClientMessageToAll bug
#1

Hello,
I'm kinda newbie with scripts

I made a teleport command with sendclientmessagetoall
The command is /hq when i type this command it teleports me to the place i want with the clientmessage

But when i type any other command like example /help, The client message which i made for the teleport shows up
But it doesn't teleport me, even if i type a random command like /143jvkfnk the message will show up X:

What i exactly mean, Check the pictures

Here i typed /hq and teleported also the message showed up


Here i typed /help which should not show the same message but it does


After typing /help


See the message saying i teleported to the HQ
This happens with every command i type

Can someone say what's wrong here?
Код:
#include <a_samp>
#define COLOR_RED 0xFF0000AA

public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/hq", cmdtext, true, 10) == 0)

		 SetPlayerPos(playerid, 213.9292, 1902.094, 17.64063);
         new string[50];
         new name[MAX_PLAYER_NAME];
         GetPlayerName(playerid,name,18);
         format(string, sizeof(string), "%s has teleported to Blood Line HQ",name);
     SendClientMessageToAll(COLOR_RED, string);

  return 1;
}
Reply
#2

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/hq", cmdtext, true, 10) == 0)
    {
         SetPlayerPos(playerid, 213.9292, 1902.094, 17.64063);
         new string[50];
         new name[MAX_PLAYER_NAME];
         GetPlayerName(playerid,name,18);
         format(string, sizeof(string), "%s has teleported to Blood Line HQ",name);
         SendClientMessageToAll(COLOR_RED, string);
     }
     return 1;
}
Reply
#3

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (!strcmp("/hq", cmdtext, true))
    {
         new string[68 /* 44 = String and 24 = MaxPlayerName  == 68! */ ], name[MAX_PLAYER_NAME];
         SetPlayerPos(playerid, 213.9292, 1902.094, 17.64063);
         GetPlayerName(playerid,name, 24); // 24's max size name
         format(string, sizeof(string), "%s has teleported to Blood Line HQ",name);
         SendClientMessageToAll(COLOR_RED, string);
    }
  return 1;
}
Reply
#4

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
      if(strcmp(cmdtext, "/hq", true, 3) == 0)
      {
         new string[50];
         new name[MAX_PLAYER_NAME];
         SetPlayerPos(playerid, 213.9292, 1902.094, 17.64063);
         GetPlayerName(playerid, name, 18);
         format(string, sizeof(string), "%s has teleported to the Blood Line HQ", name);
         SendClientMessageToAll(COLOR_RED, string);
         GameTextForPlayer(playerid, "~g~ Welcome To The Blood Line HQ", 2000, 4);
         return 1;
      }
}
return 0;
Reply
#5

3 guys posting the exact same code - logic = ?!??!!?

@sniperwars You clearly have no clue what you're doing, as there are no returns.
Reply
#6

Sorry about that, I forgot the return 1;
Reply
#7

And the return 0; at the bottom. But still, it's already been posted twice, what makes you think yours is any better when it's clearly not and wouldn't even work correctly? :L
Reply
#8

I don't think mine is better than anyone else's. It does work correctly actually.
Reply
#9

pretty much the same as sniperwars

pawn Код:
if(strcmp(cmdtext,"/hq",true)==0)
{
        SetPlayerPos(playerid,213.9292, 1902.094, 17.64063);
        GameTextForPlayer(playerid,"Blood Line HQ",4000,6);
        new pName[MAX_PLAYER_NAME], string[56];
        GetPlayerName(playerid, pName, sizeof(pName));
        format(string, sizeof(string), " %s has teleported to HQ", pName);
        SendClientMessageToAll(0xFFFF00AA, string);
        GameTextForPlayer(playerid,"Blood Line HQ",4000,6);
        print(string);
        return 1;
}
EDIT: now that i look at it my command is pretty much the same as snipewars and everyone else!!! Sorry for not reading closely!!!
Hope that helps other wise PM me and i can give you a hand on strcmp cmd help.!!!
Reply
#10

Thank you, it worked
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)