[HELP] I Get Spammed
#1

How to stop the spamming? When i drive over "120" then i get spammed this:

Yo man! Slow down!!!
The speed limit is 120! so slow down!!!


I want it like: When i drive over 120 then i get the message ONE time.


The whole filter script
pawn Код:
#include <a_samp>

forward Speed(playerid);



public OnFilterScriptInit()
{
    SetTimer("Speed",1000,1);
    return 1;
}




public Speed(playerid)
{
    for(new i; i < MAX_PLAYERS; i++)
    {
        if(GetVehicleSpeed(i) > 120)
        {
             SendClientMessage(playerid,0xFF0005FF,"Yo man! Slow down!!!");
             SendClientMessage(playerid,0xFF0005FF,"The speed limit is 120! so slow down!!!");
             return 1;
         }
     }
    return 1;
}



stock GetVehicleSpeed(i)
{
    new Float: x, Float: y, Float: z;
   
    GetVehicleVelocity(i, x, y, z);
    return floatround((floatmul(floatsqroot(floatpower(x, 2.0) + floatpower(y, 2.0) + floatpower(z, 2.0)), 100.0) / 0.4463), floatround_floor);
}
Reply
#2

The timer is each second so you will get spammed over 120. Currently you are calling the function ever 1 second so if the timer was called 10 times that means the player is over 120 constantly for 10 seconds therefore sending the message to the player 10 times.
Reply
#3

Quote:
Originally Posted by Tee
Посмотреть сообщение
The timer is each second so you will get spammed over 120. Currently you are calling the function ever 1 second so if the timer was called 10 times that means the player is over 120 constantly for 10 seconds therefore sending the message to the player 10 times.
Can you explain me more? :P

I dint really understand how Timers works xD



This forum requires that you wait 60 seconds between posts. Please try again in 12 seconds.
Reply
#4

Ok
pawn Код:
SetTimer("Example",1000,true);
[pawn]//That sets a timer with the function name "Example" and calls the function every 1 second (1000 ms = 1 second) and the timer will be repeated ever 1 second (hence the use of true and not false) True will make the timer repeat with the given time; False will make it get called only once.[pawn]

If you still don't understand, click here
Reply
#5

Ok
pawn Код:
SetTimer("Example",1000,true);
pawn Код:
//That sets a timer with the function name "Example" and calls the function every 1 second (1000 ms = 1 second) and the timer will be repeated ever 1 second (hence the use of true and not false) True will make the timer repeat with the given time; False will make it get called only once.
If you still don't understand, click here
Reply
#6

If i put:

pawn Код:
SetTimer("Speed",1000,false);
Then the text dont show when i drive over 120
Reply
#7

funny code
Try:
pawn Код:
#include <a_samp>

forward Speed();



public OnFilterScriptInit()
{
    SetTimer("Speed",1000,1);
    return 1;
}




public Speed()
{
    for(new playerid; playerid < MAX_PLAYERS; playerid++)
    {
        if(GetVehicleSpeed(playerid) > 120 && GetPVarInt(playerid,"ATTENTION") == 0)
        {
            SendClientMessage(playerid,0xFF0005FF,"Yo man! Slow down!!!");
            SendClientMessage(playerid,0xFF0005FF,"The speed limit is 120! so slow down!!!");
            SetPVarInt(playerid,"ATTENTION",1);
            return 1;
        }
        if(GetPlayerSpeed(playerid) <120 && GetPVarInt(playerid,"ATTENTION") == 1)
        {
            SetPVarInt(playerid,"ATTENTION",0);
            return 1;
        }
     }
    return 1;
}
Reply
#8

Hahah :P

And, HMMMM it dont work =/
Reply
#9

Didn't view your code as I know I'm bound to make a typo tonight, but what you could do is have a separate timer inside the if block. Have it as a boolean variable. If false, call the timer which will activate in XXXX milliseconds. Once the timer finally executes set that variable to true; hence allowing for the thing to display again.

Probably not the greatest way to go about it, but eh.
Reply
#10

Hmmm, I still get spammed... More ideas please
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)