Command/text problems
#1

Hello,

I'm making a function that will trigger when you type ! infront of the sentence. Example: !Hello my name is hanzen. Then it will send a clientmessage, but I really can't figure out how to solve this. Something that has to go under OnPlayerText or on OnPlayerCommandText, and how to do it?

Would appreciate answers
Regards Hanzen
Reply
#2

I'm sure its OnPlayerText since ! isnt a command on sa-mp but this is a good question, i could make something when the question is solved. cause i have a cod4 server :P
there must be a way to detect !%s (!text)
not sure if it works but maybe you could first format a string with !%s,text); and then use strfind and use the string. like strfind(text,string,blah blah
Reply
#3

Quote:
Originally Posted by Mike_Peterson
Посмотреть сообщение
I'm sure its OnPlayerText since ! isnt a command on sa-mp but this is a good question, i could make something when the question is solved. cause i have a cod4 server :P
there must be a way to detect !%s (!text)
not sure if it works but maybe you could first format a string with !%s,text); and then use strfind and use the string. like strfind(text,string,blah blah
Yeah, code suggestions? Still pretty insecure.
Reply
#4

I tried what you said, and it works in a way. But it also works if you type hello! I want to set it so the ! has to be at the start.
Reply
#5

Try this:

pawn Код:
public OnPlayerText(playerid, text[])
{
     if(text[0] == '!')
     {
          // do stuff here
     }
     return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)