SA-MP Forums Archive
Spamming message! - 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: Spamming message! (/showthread.php?tid=649012)



Spamming message! - RedRex - 01.02.2018

Hello I've making a command for a robbing and After the robbing succesfuly they are spamming the message FORMAT

PHP код:
forward FourDragonRobbery();
public 
FourDragonRobbery()
{
         for(new 
i=0i<MAX_PLAYERSi++)
        {
            if(
IsPlayerConnected(i)) // checking if player connected
            
{
                
//ROBBERIES
                  
if(ROBBING_FourDragon[i] > 1// Checking if robbery time is above 1
                
{
                    
ROBBING_FourDragon[i] --; // Decreasing time
                    
new time[20]; //adding time variable
                      
format(time,sizeof(time),"%d",ROBBING_FourDragon[i]);
                      
TextDrawSetString(Textdraw494time);
                    
TextDrawShowForPlayer(iTextdraw492);
                    
TextDrawShowForPlayer(iTextdraw493);
                    
TextDrawShowForPlayer(iTextdraw494);
                    
TextDrawShowForPlayer(iTextdraw495);
                    
ApplyAnimation(i"ROB_BANK""CAT_Safe_Rob"4.1111111);
                }
                if(
ROBBING_FourDragon[i] == 1// IF the timer reached 1
                
{
                    new 
string[150], pName[MAX_PLAYER_NAME];// getting player name
                    
GetPlayerName(i,pName,MAX_PLAYER_NAME);
                    
SetPlayerWantedLevel(iGetPlayerWantedLevel(i) + 5); //giving player 5 wanted level
                    
SetPlayerColor(iCOLOR_ORANGE);
                    new 
mrand =random(200000);
                    
ROBBING_FourDragon[i] = 0// Complete the timer for next step!
                    
TextDrawHideForPlayer(iTextdraw494);
                    
format(string,sizeof(string),"[Four Dragon]: %s(%d) has robbed Four Dragon Casino and collect: $%d.",pName,i,mrand);
                    
SendClientMessageToAll(COLOR_REDstring);
                    
                    
ROBBING_FourDragon[i] = 1// Complete the timer for next step!
                     
SetPlayerRaceCheckpoint(i1750.7642,382.4462,23.1719,263.0588,0,02);
                     
SetTimer("FourDragonFinal",300000,true);
                    
TimeM 3;
                    
TimeS 0;
                    
Time SetTimer("UpdateTime"1000true);
                    
TextDrawShowForPlayer(iTextdraw494);
                }
            }
        }
        return 
1;




Re: Spamming message! - Flamehaze7 - 01.02.2018

Just get the formatted string outside the loop and you'll have no problems


Re: Spamming message! - N0FeaR - 01.02.2018

Try this

PHP код:
forward FourDragonRobbery();
public 
FourDragonRobbery()
{
    if(
IsPlayerConnected(i)) // checking if player connected
    
{
         
//ROBBERIES
           
if(ROBBING_FourDragon[i] > 1// Checking if robbery time is above 1
         
{
              
ROBBING_FourDragon[i] --; // Decreasing time
              
new time[20]; //adding time variable
            
format(time,sizeof(time),"%d",ROBBING_FourDragon[i]);
             
TextDrawSetString(Textdraw494time);
              
TextDrawShowForPlayer(iTextdraw492);
               
TextDrawShowForPlayer(iTextdraw493);
               
TextDrawShowForPlayer(iTextdraw494);
            
TextDrawShowForPlayer(iTextdraw495);
            
ApplyAnimation(i"ROB_BANK""CAT_Safe_Rob"4.1111111);
        }
          if(
ROBBING_FourDragon[i] == 1// IF the timer reached 1
        
{
             new 
string[150], pName[MAX_PLAYER_NAME];// getting player name
               
GetPlayerName(i,pName,MAX_PLAYER_NAME);
             
SetPlayerWantedLevel(iGetPlayerWantedLevel(i) + 5); //giving player 5 wanted level
              
SetPlayerColor(iCOLOR_ORANGE);
               new 
mrand =random(200000);
            
ROBBING_FourDragon[i] = 0// Complete the timer for next step!
            
TextDrawHideForPlayer(iTextdraw494);
            
format(string,sizeof(string),"[Four Dragon]: %s(%d) has robbed Four Dragon Casino and collect: $%d.",pName,i,mrand);
            
SendClientMessageToAll(COLOR_REDstring);
            
ROBBING_FourDragon[i] = 1// Complete the timer for next step!
               
SetPlayerRaceCheckpoint(i1750.7642,382.4462,23.1719,263.0588,0,02);
              
SetTimer("FourDragonFinal",300000,true);
            
TimeM 3;
             
TimeS 0;
              
Time SetTimer("UpdateTime"1000true);
               
TextDrawShowForPlayer(iTextdraw494);
           }
    }
    return 
1;




Re: Spamming message! - Mugala - 01.02.2018

this code is messed up, is this timer starts from ongamemodeinit or from where?


Re: Spamming message! - RedRex - 01.02.2018

Quote:
Originally Posted by N0FeaR
Посмотреть сообщение
Try this

PHP код:
forward FourDragonRobbery();
public 
FourDragonRobbery()
{
    if(
IsPlayerConnected(i)) // checking if player connected
    
{
         
//ROBBERIES
           
if(ROBBING_FourDragon[i] > 1// Checking if robbery time is above 1
         
{
              
ROBBING_FourDragon[i] --; // Decreasing time
              
new time[20]; //adding time variable
            
format(time,sizeof(time),"%d",ROBBING_FourDragon[i]);
             
TextDrawSetString(Textdraw494time);
              
TextDrawShowForPlayer(iTextdraw492);
               
TextDrawShowForPlayer(iTextdraw493);
               
TextDrawShowForPlayer(iTextdraw494);
            
TextDrawShowForPlayer(iTextdraw495);
            
ApplyAnimation(i"ROB_BANK""CAT_Safe_Rob"4.1111111);
        }
          if(
ROBBING_FourDragon[i] == 1// IF the timer reached 1
        
{
             new 
string[150], pName[MAX_PLAYER_NAME];// getting player name
               
GetPlayerName(i,pName,MAX_PLAYER_NAME);
             
SetPlayerWantedLevel(iGetPlayerWantedLevel(i) + 5); //giving player 5 wanted level
              
SetPlayerColor(iCOLOR_ORANGE);
               new 
mrand =random(200000);
            
ROBBING_FourDragon[i] = 0// Complete the timer for next step!
            
TextDrawHideForPlayer(iTextdraw494);
            
format(string,sizeof(string),"[Four Dragon]: %s(%d) has robbed Four Dragon Casino and collect: $%d.",pName,i,mrand);
            
SendClientMessageToAll(COLOR_REDstring);
            
ROBBING_FourDragon[i] = 1// Complete the timer for next step!
               
SetPlayerRaceCheckpoint(i1750.7642,382.4462,23.1719,263.0588,0,02);
              
SetTimer("FourDragonFinal",300000,true);
            
TimeM 3;
             
TimeS 0;
              
Time SetTimer("UpdateTime"1000true);
               
TextDrawShowForPlayer(iTextdraw494);
           }
    }
    return 
1;

Its not worked....

Quote:
Originally Posted by Mugalito
Посмотреть сообщение
this code is messed up, is this timer starts from ongamemodeinit or from where?
Missed up? what do you mean? I've adding everything

guys just help me wtih the Message its spamming ...


Re: Spamming message! - GangstaSunny. - 01.02.2018

PHP код:
ROBBING_FourDragon[i] = 1// Complete the timer for next step! 
If you are setting this variable INSIDE the loop, it will always be one (1), no wonder your message is spamming.


Re: Spamming message! - RedRex - 01.02.2018

Quote:
Originally Posted by GangstaSunny.
Посмотреть сообщение
PHP код:
ROBBING_FourDragon[i] = 1// Complete the timer for next step! 
If you are setting this variable INSIDE the loop, it will always be one (1), no wonder your message is spamming.
So I must do it ROBBING_FourDragon[i] = 0;?


Re: Spamming message! - Flamehaze7 - 01.02.2018

Код:
forward FourDragonRobbery();
public FourDragonRobbery()
{
        new TimerCompleted[MAX_PLAYERS];
        for(new i=0; i<MAX_PLAYERS; i++)
        {
            if(IsPlayerConnected(i)) // checking if player connected
            {
                //ROBBERIES
                  if(ROBBING_FourDragon[i] > 1) // Checking if robbery time is above 1
                {
                    ROBBING_FourDragon[i] --; // Decreasing time
                    new time[20]; //adding time variable
                      format(time,sizeof(time),"%d",ROBBING_FourDragon[i]);
                      TextDrawSetString(Textdraw494, time);
                    TextDrawShowForPlayer(i, Textdraw492);
                    TextDrawShowForPlayer(i, Textdraw493);
                    TextDrawShowForPlayer(i, Textdraw494);
                    TextDrawShowForPlayer(i, Textdraw495);
                    ApplyAnimation(i, "ROB_BANK", "CAT_Safe_Rob", 4.1, 1, 1, 1, 1, 1, 1);

                }
                if(ROBBING_FourDragon[i] == 1) // IF the timer reached 1
                {
                    SetPlayerWantedLevel(i, GetPlayerWantedLevel(i) + 5); //giving player 5 wanted level
                    SetPlayerColor(i, COLOR_ORANGE);
                    
                    ROBBING_FourDragon[i] = 0; // Complete the timer for next step!
                    TimerCompleted[i] = 1; //set this to 1 so we can call it back later
                    TextDrawHideForPlayer(i, Textdraw494);
                    
                    ROBBING_FourDragon[i] = 1; // Complete the timer for next step!
                     SetPlayerRaceCheckpoint(i, 1, 750.7642,382.4462,23.1719,263.0588,0,0, 2);
                     SetTimer("FourDragonFinal",300000,true);
                    TimeM = 3;
                    TimeS = 0;
                    Time = SetTimer("UpdateTime", 1000, true);
                    TextDrawShowForPlayer(i, Textdraw494);
                }
            }
        }
        if(TimerCompleted[playerid] == 1) 
        {
            new mrand =random(200000);
            new string[150], pName[MAX_PLAYER_NAME];// getting player name
            GetPlayerName(i,pName,MAX_PLAYER_NAME);
            format(string,sizeof(string),"[Four Dragon]: %s(%d) has robbed Four Dragon Casino and collect: $%d.",pName,i,mrand);
            SendClientMessageToAll(COLOR_RED, string);
        }
        return 1;
}
I'm not sure about this 'cause i couldn't look much at your script but i made something.


Re: Spamming message! - Mugala - 01.02.2018

and when FourDragonRobbery() <-- is called? or if it's timer, can u show me a timer code?


Re: Spamming message! - RedRex - 01.02.2018

hello, My problem is only here.. Spamming this message Did I place it in wrong place?

format(string,sizeof(string),"[Four Dragon]: %s(%d) has robbed Four Dragon Casino and collect: $%d.",pName,i,mrand);
SendClientMessageToAll(COLOR_RED, string);