Sounds? -
Lajko1 - 17.11.2013
Hey guys I have this code:
pawn Код:
public OnPlayerText(playerid, text[])
{
if(text[0] == '-')
{
new string[100];
new sendername[MAX_PLAYER_NAME];
GetPlayerName(playerid, sendername, sizeof(sendername));
format(string, sizeof(string),"::.Dispatch.:: %s: %s", sendername,text[1]);
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerCop(i))
{
SendClientMessage(i,0x0FFDD349,string);
}
}
return 0;
}
This is dispatch chat for cops, but listen up what I want to make, how can I make if player will write the fallowing:
"-Suspect is in water" it will play sound id 2606
Or how can I make if player will write:
"-Suspect is driving in black "jeep" " it will play sound id 3028
So I would somehow detect what is player writing ... not full sentence maybe only 1 word, how can I script this?
Re: Sounds? -
DeStunter - 17.11.2013
Код:
new Float:pos[3];
GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
PlayerPlaySound(playerid, 2606, pos[0], pos[1], pos[2]);
http://lmgtfy.com/?q=samp+playerplaysound
https://sampwiki.blast.hk/wiki/PlayerPlaySound
Re: Sounds? -
Lajko1 - 17.11.2013
Well comic you didn't understand, what I'm asking for, I know how to use sounds and apply them but I don't know how should I make if player will write in dispatch chat word "jeep" it will play sound id 3028
Re: Sounds? -
DeStunter - 17.11.2013
You can use the strfind to find key words/phrases like "driving in", "in water". or a bank of words like "Jeep", "truck", "bus" so forth. And check every single one.
edit-
strfind will return where the word/phrase starts so you could do:
Код:
if((strfind(text, "driving in") > 0) && (strfind(text, "jeep") > 0))
{
...
}
Re: Sounds? -
Lajko1 - 17.11.2013
Well this is exactly what I wanted, thank you and rep+ for you
just 1 more question, is possible to combine sounds? for example:
"-Suspect is driving black jeep" it will play sound id 2200 (black) and after this it will play sound id 3028 (jeep) is possible to do that?
Re: Sounds? -
DeStunter - 17.11.2013
I don't think there is a way to tell it to play at the end of it self, but you could time how long it takes to play (black) set a timer to call (jeep) once black is done.
Re: Sounds? -
Lajko1 - 17.11.2013
Well I was thinking about adding timer also
well thank you
Re: Sounds? -
Lajko1 - 17.11.2013
1 more thing how to set it so it won't detect capital letters ?
Re: Sounds? -
DeStunter - 18.11.2013
Quote:
Originally Posted by Lajko1
1 more thing how to set it so it won't detect capital letters ?
|
https://sampwiki.blast.hk/wiki/Strfind
that should help you.