SA-MP Forums Archive
Looking for a Script for automatic reply. - 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)
+--- Thread: Looking for a Script for automatic reply. (/showthread.php?tid=646190)



Looking for a Script for automatic reply. - alvin6 - 12.12.2017

Hi,
I am looking for script for auto reply to a question like when a player ask How to be a police? then in chatbox server reply automatic like Hey, (Playernamehere) you can start police job by entering in a police vehicle and type /job.

Just like that...
Can anyone help?


Re: Looking for a Script for automatic reply. - solstice_ - 12.12.2017

PHP код:
#define COLOR_WHITE 0xFFFFFFAA 
PHP код:
public OnPlayerText(playeridtext[])
{
    {
        new 
string[400], playername[MAX_PLAYER_NAME];
        
GetPlayerName(playeridplayernamesizeof(playername));
        
format(stringsizeof(string), "%s: %s"playernametext);
        
SendClientMessageToAll(-1string);
    }
    if(
strfind(text"How to be a police"true) != -1)
    {
        new 
string[400];
        new 
playername[MAX_PLAYER_NAME];
        
GetPlayerName(playeridplayernamesizeof(playername));
        
format(stringsizeof(string), "Hey, %s you can be a police by entering in a police vehicle and type /job. "GetPlayerNameEx(playerid));
        
SendClientMessage(playeridCOLOR_WHITEstring);
    }
    return 
0;
}

PHP код:
stock GetPlayerNameEx(playerid)
{
    new
        
sz_playerName[MAX_PLAYER_NAME],
        
i_pos;
    
GetPlayerName(playeridsz_playerNameMAX_PLAYER_NAME);
    while ((
i_pos strfind(sz_playerName"_"falsei_pos)) != -1sz_playerName[i_pos] = ' ';
    return 
sz_playerName;

Not sure if it will work it's not tested as i can't compile it right now, tell me if it works or not.


Re: Looking for a Script for automatic reply. - Sithis - 12.12.2017

Sign up for an account at http://wit.ai -> Create intent "police duty" using their system -> Send every OnPlayerText to Wit.ai -> Respond with police explanation when intent "police duty" is detected.


Re: Looking for a Script for automatic reply. - jasperschellekens - 12.12.2017

use a timer or else it will send the answer before the player send his message.
Код:
//==============================================================================
public OnPlayerText(playerid,text[])
{
if(strfind(text, "Hello Chatman", true) != -1 || strfind(text, "Hey chatman", true) != -1 || strfind(text, "Hi chatman", true) != -1 ||
	 strfind(text, "Hey chatman", true) != -1 || strfind(text, "Hey, chatman", true) != -1|| strfind(text, "Hi, chatman", true) != -1 || strfind(text, "Hello, chatman", true) != -1)
    {
        Chatman(playerid, 1000);
    }
return 1;
}
//==============================================================================
stock Chatman(playerid, time)
{
	SetTimerEx("Chatman2", time, false, "i", playerid);
}
forward Chatman2(playerid);
public Chatman2(playerid)
{
		new String[128];
        format(String,sizeof(String),"{FFFFFF}{FF0000}Chatman(1337): {FFFFFF}Hello there, %s .",GetPlayerName(playerid));
        SendClientMessageToAll(RED,String);
}