Problem with cmd - 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: Problem with cmd (
/showthread.php?tid=175222)
Problem with cmd -
Daniele_Pelle - 08.09.2010
Hello guys, I want to create a script that when a player type "lol" is applied to the animation and get an action.
I put this in OnPlayerText but it not work.
pawn Код:
new sendername[MAX_PLAYER_NAME];
if (strcmp("lol", tmp, true) == 0)
{
format(string, sizeof(string), "* %s ride con gusto", sendername);
ApplyAnimation(playerid, "RAPPING", "Laugh_01", 4.0, 0, 0, 0, 0, 0, 1);
return 1;
}
I try to put in OnPlayerCommandText with this code:
pawn Код:
if (strcmp("lol", cmdtext, true) == 0)
{
format(string, sizeof(string), "* %s ride con gusto", sendername);
ApplyAnimation(playerid, "RAPPING", "Laugh_01", 4.0, 0, 0, 0, 0, 0, 1);
return 1;
}
is compiled successfully, but does not work in any case
Sorry for my bad english з_з
Re: Problem with cmd -
Daniele_Pelle - 09.09.2010
up......
Re: Problem with cmd -
Mikkel_Pedersen - 09.09.2010
OnPlayerCommandText is called when you start the text with '/'. If you want it to work add a '/' infront of the "lol". If you want it to happen to people who type it in the chat use OnPlayerText
Re: Problem with cmd -
MartinDee - 09.09.2010
pawn Код:
public OnPlayerText;
{
new sendername[MAX_PLAYER_NAME];
new idx;
tmp = strtok(text, idx);
if (strcmp("lol", tmp, true) == 0)
{
format(string, sizeof(string, "* %s ride con gusto", sendername);
ApplyAnimation(playerid, "RAPPING", "Laugh_01", 4.0, 0, 0, 0, 0, 0, 1);
return 1;
}
return 0;
}
// I hope you have string set.. new string[ 128 ];
// + If you edditing some mod, than you will have strtok, if not, say me..
// Not tested, but should work..
Re: Problem with cmd -
Daniele_Pelle - 09.09.2010
Quote:
Originally Posted by Mikkel_Pedersen
OnPlayerCommandText is called when you start the text with '/'. If you want it to work add a '/' infront of the "lol". If you want it to happen to people who type it in the chat use OnPlayerText
|
I try tu put in OnPlayerText but it not work. When I type "lol" appares lol in chat, but not appares the anim or the actions
Quote:
Originally Posted by MartinDee
pawn Код:
public OnPlayerText; { new sendername[MAX_PLAYER_NAME]; new idx; tmp = strtok(text, idx); if (strcmp("lol", tmp, true) == 0) { format(string, sizeof(string, "* %s ride con gusto", sendername); ApplyAnimation(playerid, "RAPPING", "Laugh_01", 4.0, 0, 0, 0, 0, 0, 1); return 1; } return 0; } // I hope you have string set.. new string[ 128 ]; // + If you edditing some mod, than you will have strtok, if not, say me.. // Not tested, but should work..
|
Ok im going to test.
Re: Problem with cmd -
LarzI - 09.09.2010
Quote:
Originally Posted by MartinDee
pawn Код:
public OnPlayerText; { new sendername[MAX_PLAYER_NAME]; new idx; tmp = strtok(text, idx); if (strcmp("lol", tmp, true) == 0) { format(string, sizeof(string, "* %s ride con gusto", sendername); ApplyAnimation(playerid, "RAPPING", "Laugh_01", 4.0, 0, 0, 0, 0, 0, 1); return 1; } return 0; } // I hope you have string set.. new string[ 128 ]; // + If you edditing some mod, than you will have strtok, if not, say me.. // Not tested, but should work..
|
Why the hell do you use strtok?
pawn Код:
public OnPlayerText(playerid, text[])
{
if(!strcmp(text, "lol", true))
{
new sendername[24], string[40];
GetPlayerName(playerid, sendername, sizeof(sendername));
ApplyAnimation(playerid, "RAPPING", "Laugh_01", 4.0, 0, 0, 0, 0, 0, 1);
format(string, sizeof(string, "* %s ride con gusto", sendername);
return SendClientMessageToAll(0xFFFFFFFF, string);
}
return 1;
}
Re: Problem with cmd -
New_Player[USW] - 09.09.2010
You need to put /lol for the cmd to work.Making it lol only would not work.
Re: Problem with cmd -
LarzI - 09.09.2010
If you were talking to me, stop saying things you don't know.