[C++] GetTickCount();

ejexter

Well-known member
Joined
Feb 21, 2014
Messages
211
Reaction score
0
Code:
unsigned int uiPMChatFloodIntervalPlayer;
DWORD iLastSentFloodPMFloodLocal = GetTickCount();

Code:
if( cheat_state->_generic.Kaki_PMFlood_Hooked)
	{
		if(GetTickCount() - iLastSentFloodPMFloodLocal >= uiPMChatFloodIntervalPlayer)
		{
			XPMFlood();
			iLastSentFloodPMFloodLocal = GetTickCount();
		}
	}
How to set delay for 2 Second (2000ms) in this code ??  :forever_hurra:
 

T3KTONIT

Well-known member
Joined
Sep 2, 2013
Messages
308
Reaction score
5
put it in the thread loop....


Code:
While(0)   // -- This is the start of the thread loop / main loop (don't add this to your code, or you will go to an infinite  loop)
{

if(GetTickCount() - iLastSentFloodPMFloodLocal >= 2000) // CurrentTickCount - lastTickCount, Tickcounts in millieseconds (this counts how much millieseconds have passed...)
		{
			XPMFlood();
			iLastSentFloodPMFloodLocal = GetTickCount(); // Set to current time.
		}

}
 

ejexter

Well-known member
Joined
Feb 21, 2014
Messages
211
Reaction score
0
Thanks on the interview of GetTickCount(), [member=5679]T3K[/member]  :urtheman:
but is keep spamming!  :bawww:
I want every 2000ms this send message (fuckin' Anti-Flood...)  :face_palm:

Code:
void XPMFlood ( void )
{
	for (int i = 0; i < SAMP_PLAYER_MAX; i++ )
	{
		if ( g_Players->iIsListed[i] != 1 )
		continue;
		if(g_Players->pRemotePlayer[i] == NULL)
		continue;
		say("/pm %d FUCK U!", i);
	}
	return;
}
 

T3KTONIT

Well-known member
Joined
Sep 2, 2013
Messages
308
Reaction score
5
Well you are sending everyone a pm...

do you want to send a PM every 2000ms ?
 
Joined
Feb 18, 2005
Messages
2,965
Reaction score
273
You need to add the delay in that for, so it sends a pm every 2sec.

Code:
unsigned int delay;

void XPMFlood ( void )
{
	for (int i = 0; i < SAMP_PLAYER_MAX; i++ )
	{
		if ( g_Players->iIsListed[i] != 1 )
		continue;
		if(g_Players->pRemotePlayer[i] == NULL)
		continue;
		
		do {
			if (delay < (GetTickCount() - 2000)) {
				break;
			}		
		} while (1);
		say("/pm %d FUCK U!", i);
	        delay = GetTickCount();
	}
	return;
}
 

ejexter

Well-known member
Joined
Feb 21, 2014
Messages
211
Reaction score
0
Thanks [member=111]springfield[/member]  :urtheman:
I will try this  :somuchwin:
 

T3KTONIT

Well-known member
Joined
Sep 2, 2013
Messages
308
Reaction score
5
springfield link said:
You need to add the delay in that for, so it sends a pm every 2sec.

Code:
unsigned int delay;

void XPMFlood ( void )
{
	for (int i = 0; i < SAMP_PLAYER_MAX; i++ )
	{
		if ( g_Players->iIsListed[i] != 1 )
		continue;
		if(g_Players->pRemotePlayer[i] == NULL)
		continue;
		
		do {
			if (delay < (GetTickCount() - 2000)) {
				break;
			}		
		} while (1);
		say("/pm %d FUCK U!", i);
	        delay = GetTickCount();
	}
	return;
}

That won't work...

or at least, it will be buggy as fuck, Unless you create a thread for it
because if XPMFlood(); is called, the thread will freeze because of the infinite loop do while(1)
that's just as equivalent as Sleep(2000); which is not so convenient...


the answer is just add this :
Code:
			if (delay < (GetTickCount() - 2000)) 
                            {
				//code here
                               delay = GetTickCount();
                            }

in a live thread.

this is an example :
PHP:
#include <windows.h>
unsigned int delay = 0;
int main()
{
      while(0) // this is the loop that keeps the thread going.
      {
			if (delay < (GetTickCount() - 2000)) 
                            {
                               printf("Hello World");
                               delay = GetTickCount();
                            }
      }
      return 0;
}
 
Joined
Feb 18, 2005
Messages
2,965
Reaction score
273
Then he'll need to use something else than for. I don't think he knows how.

Another shitty idea  :ppffh:
Code:
HANDLE spamThread;
bool spamState = false;

void  XPMFlood () {
	if (spamThread == NULL) [
		spamThread = CreateThread(0, 0, (LPTHREAD_START_ROUTINE)spamThread, 0, 0, 0);
	]
	else {
		if (!spamState) return;
		TerminateThread(spamThread); spamThread = 0;	
	}
}
 

0x_

Wtf I'm not new....
Staff member
Administrator
Joined
Feb 18, 2013
Messages
1,123
Reaction score
177
Go the swag way:
std::vector<> <- list of people to spam

if list < 1 == add all players.

have some basic delay code in a loop and take the last list entry and send the message and then delete it, so you're queueing everything bascially.
 
Top