FS code to combine with GM
#1

Hi, all. I am practicing on game-modes using Jafet_Macario's beginner GM. As i have posted my first filter-script, ClientMessage, i want to combine that with the GM.

I know that i have to replace OnFilterScriptInit to OnGameModeInit, and OnFilterScriptExit to OnGameModeExit, can i have a complete command on which code to replace with which code? I am a beginner, learning in PAWNO, so please help me.
Reply
#2

If the commands were in "strcmp" put them in callback 'OnPlayerCommandText'.
Reply
#3

I seen your Client message and here how to blind it
Put this under #include <a_samp> #include <sscanf2>
Would look like this
PHP код:
#include <a_samp> 
 #include <sscanf2> 
Put this with the defines, under the includes
PHP код:
#define MAX_LINES 10
#define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1 
Put this any where is in script, just not in any Call Back
PHP код:
forward MessageTimer();
new 
Lines[MAX_LINES][256];
new 
TIME_FOR_EACH_MESSAGE 60//Time in seconds
new MessageTimerS;
stock ReadFileLine(File:name)
{
    new 
str[256];
    for(new 
linez 0linez != 1linez++)
    {
        
fread(namestr);
    }
    return 
str;
}
stock ReadLines()
{
    new 
File:Messages fopen("messages.txt"io_read);
    for(new 
dlines 0dlines MAX_LINESdlines++)
    {
        
format(Lines[dlines],256,"%s",ReadFileLine(Messages));
    }
    
fclose(Messages);

Put this also any where is the script just not in any call back
PHP код:
public MessageTimer()
{
    new 
rand random(MAX_LINES);
    
SendClientMessageToAll(0xFFFFFFAALines[rand]);
    print(
Lines[rand]);
    return 
1;

Put this under OnPlayerCommandText
PHP код:
    dcmd(setline7cmdtext);
    
dcmd(messagetime11cmdtext);
    if (
strcmp("/starttimer"cmdtexttrue) == 0)
    {
        if(
IsPlayerAdmin(playerid))
        {
            if(
MessageTimerS != 0)
            {
               
KillTimer(MessageTimerS);
                
MessageTimerS 0;
                
SendClientMessage(playerid0xFF8040FF"The Message Timer has been deactivated.");
            }
            else
            {
                
MessageTimerS SetTimer("MessageTimer"TIME_FOR_EACH_MESSAGE*1000true);
                
SendClientMessage(playerid0xFF8040FF"The Message Timer has been activated.");
            }
        }
        return 
1;
    } 
Put this any where in the script just not in any Call Back
PHP код:
dcmd_setline(playeridparams[])     //This will NOT save the lines in messages.txt! It will only save the variable.
{                                   //The next version you will be able to save it in messages.txt
    
new linemessage[256];
    if(
IsPlayerAdmin(playerid))
    {
        if(
sscanf(params"is[256]"linemessage)) return SendClientMessage(playerid0xFF8040FF"USAGE: /setline [line] [message]");
        if(
strlen(message) > 256) return SendClientMessage(playerid0xFF8040FF"ERROR: Message too long!");
        if(
line MAX_LINES+|| line 1) return SendClientMessage(playerid0xFF8040FF"ERROR: This line doesn't exist!");
        
format(Lines[line-1], 256"%s"message);
        
format(messagesizeof(message), "[LINE %i]{FF8040} has changed into: %s"linemessage);
        
SendClientMessage(playerid0xFFC68CFFmessage);
    }
    return 
1;
}
dcmd_messagetime(playeridparams[])
{
    new 
string[53], time;
    if(
IsPlayerAdmin(playerid))
    {
        if(
sscanf(params"i"time)) return SendClientMessage(playerid0xFF8040FF"USAGE: /timemessage [seconds]");
        
KillTimer(MessageTimerS);
        
TIME_FOR_EACH_MESSAGE time;
        
MessageTimerS SetTimer("MessageTimer"TIME_FOR_EACH_MESSAGE*1000true);
        
format(stringsizeof(string), "The messages will now display once every %i seconds"TIME_FOR_EACH_MESSAGE);
        
SendClientMessage(playerid0xFF8040FFstring);
    }
    return 
1;

Reply
#4

Quote:
Originally Posted by DaRk_RaiN
Посмотреть сообщение
I seen your Client message and here how to blind it
Put this under #include <a_samp> #include <sscanf2>
Would look like this
PHP код:
#include <a_samp> 
 #include <sscanf2> 
Put this with the defines, under the includes
PHP код:
#define MAX_LINES 10
#define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1 
Put this any where is in script, just not in any Call Back
PHP код:
forward MessageTimer();
new 
Lines[MAX_LINES][256];
new 
TIME_FOR_EACH_MESSAGE 60//Time in seconds
new MessageTimerS;
stock ReadFileLine(File:name)
{
    new 
str[256];
    for(new 
linez 0linez != 1linez++)
    {
        
fread(namestr);
    }
    return 
str;
}
stock ReadLines()
{
    new 
File:Messages fopen("messages.txt"io_read);
    for(new 
dlines 0dlines MAX_LINESdlines++)
    {
        
format(Lines[dlines],256,"%s",ReadFileLine(Messages));
    }
    
fclose(Messages);

Put this also any where is the script just not in any call back
PHP код:
public MessageTimer()
{
    new 
rand random(MAX_LINES);
    
SendClientMessageToAll(0xFFFFFFAALines[rand]);
    print(
Lines[rand]);
    return 
1;

Put this under OnPlayerCommandText
PHP код:
    dcmd(setline7cmdtext);
    
dcmd(messagetime11cmdtext);
    if (
strcmp("/starttimer"cmdtexttrue) == 0)
    {
        if(
IsPlayerAdmin(playerid))
        {
            if(
MessageTimerS != 0)
            {
               
KillTimer(MessageTimerS);
                
MessageTimerS 0;
                
SendClientMessage(playerid0xFF8040FF"The Message Timer has been deactivated.");
            }
            else
            {
                
MessageTimerS SetTimer("MessageTimer"TIME_FOR_EACH_MESSAGE*1000true);
                
SendClientMessage(playerid0xFF8040FF"The Message Timer has been activated.");
            }
        }
        return 
1;
    } 
Put this any where in the script just not in any Call Back
PHP код:
dcmd_setline(playeridparams[])     //This will NOT save the lines in messages.txt! It will only save the variable.
{                                   //The next version you will be able to save it in messages.txt
    
new linemessage[256];
    if(
IsPlayerAdmin(playerid))
    {
        if(
sscanf(params"is[256]"linemessage)) return SendClientMessage(playerid0xFF8040FF"USAGE: /setline [line] [message]");
        if(
strlen(message) > 256) return SendClientMessage(playerid0xFF8040FF"ERROR: Message too long!");
        if(
line MAX_LINES+|| line 1) return SendClientMessage(playerid0xFF8040FF"ERROR: This line doesn't exist!");
        
format(Lines[line-1], 256"%s"message);
        
format(messagesizeof(message), "[LINE %i]{FF8040} has changed into: %s"linemessage);
        
SendClientMessage(playerid0xFFC68CFFmessage);
    }
    return 
1;
}
dcmd_messagetime(playeridparams[])
{
    new 
string[53], time;
    if(
IsPlayerAdmin(playerid))
    {
        if(
sscanf(params"i"time)) return SendClientMessage(playerid0xFF8040FF"USAGE: /timemessage [seconds]");
        
KillTimer(MessageTimerS);
        
TIME_FOR_EACH_MESSAGE time;
        
MessageTimerS SetTimer("MessageTimer"TIME_FOR_EACH_MESSAGE*1000true);
        
format(stringsizeof(string), "The messages will now display once every %i seconds"TIME_FOR_EACH_MESSAGE);
        
SendClientMessage(playerid0xFF8040FFstring);
    }
    return 
1;

Thanks a-lot, dcmd works well in the GM, right?

Also, does this have to come before the defines or after define?
Reply
#5

If you mean the publics and forwards? just put them on bottom of it.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)