Random Messages
#1

Hi Guys,
I am trying to make a message for my server that appears automatically on th chatbox e.g:

Код:
" Don't Forget to visit our Forums at www.comingsoon.com "
Can Anybody help me? I will really appreciate your help.

Regards,
Compiler
Reply
#2

There's a tutorial on the wiki.

https://sampwiki.blast.hk/wiki/Random_Messages
Reply
#3

first add the following under OnGameModeInit
PHP код:
SetTimer("RandomMessage"60000true);
// 60000ms = 60 seconds = 1 minute change it to your desire 
then some where in your script(NOT under a callback) add the following
PHP код:
forward RandomMessage();
public 
RandomMessage();
{
    
SendClientMessageToAll(-1,"YOUR MESSAGE HERE");

just replace YOUR MESSAGE HERE with the message you want to send
Reply
#4

PHP код:
#include <a_samp>
#define        MAX_MESSAGES        5     //Change accordingly
#define        MAX_MESSAGE_TEXT    128 //Change accordingly
#define     MESSAGE_COLOR        -1  //Change This
new message_array[MAX_MESSAGES][MAX_MESSAGE_TEXT]=
{
    
" Don't Forget to visit our Forums at www.comingsoon.com ",
    
" Use /levels to check the levels available ",
    
" Test Message ",
    
" Test Message ",
    
" Test Message "
};
forward RandomMessage(); 
public 
RandomMessage()

    new 
messageid random(MAX_MESSAGE);
    
SendClientMessageToAll(MESSAGE_COLORmessage_array[messageid]);
    return 
1;
}  
public 
OnGameModeInit()
{
    
SetTimer("RandomMessage"60000true); 
    return 
1;

Just made xTURBOx's code better.. So, credits to him
Reply
#5

I get These Problems:

Код:
D:\Samp Server Creating\Server\filterscripts\messages.pwn(12) : error 001: expected token: "-string end-", but found "-identifier-"
D:\Samp Server Creating\Server\filterscripts\messages.pwn(15) : error 010: invalid function or declaration
D:\Samp Server Creating\Server\filterscripts\messages.pwn(21) : error 017: undefined symbol "MAX_MESSAGE"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


3 Errors.
Reply
#6

PHP код:
#include <a_samp>
#define        MAX_MESSAGES        5     //Change accordingly
#define        MAX_MESSAGE_TEXT    128 //Change accordingly
#define         MESSAGE_COLOR        -1  //Change This
new message_array[MAX_MESSAGES][MAX_MESSAGE_TEXT]=
{
    
" Don't Forget to visit our Forums at www.comingsoon.com ",
    
" Use /levels to check the levels available ",
    
" Test Message ",
    
" Test Message ",
    
" Test Message "
};
forward RandomMessage();
public 
RandomMessage()
{
    new 
messageid random(MAX_MESSAGES);
    
SendClientMessageToAll(MESSAGE_COLORmessage_array[messageid]);
    return 
1;
}
public 
OnGameModeInit()
{
    
SetTimer("RandomMessage"60000true);
    return 
1;

The above compiles fine for me.. Copy paste and try again
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)