SendClientMessageToAll bug -
OBSERVADOR - 24.03.2012
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;
}
Re: SendClientMessageToAll bug -
antonio112 - 24.03.2012
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;
}
Re: SendClientMessageToAll bug -
DarkScripter - 24.03.2012
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;
}
Re: SendClientMessageToAll bug -
sniperwars - 25.03.2012
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;
Re: SendClientMessageToAll bug -
MP2 - 25.03.2012
3 guys posting the exact same code - logic = ?!??!!?
@sniperwars You clearly have no clue what you're doing, as there are no returns.
Re: SendClientMessageToAll bug -
sniperwars - 25.03.2012
Sorry about that, I forgot the return 1;
Re: SendClientMessageToAll bug -
MP2 - 25.03.2012
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
Re: SendClientMessageToAll bug -
sniperwars - 25.03.2012
I don't think mine is better than anyone else's. It does work correctly actually.
Re: SendClientMessageToAll bug -
nickdodd25 - 25.03.2012
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.!!!
Re: SendClientMessageToAll bug -
OBSERVADOR - 25.03.2012
Thank you, it worked