View Single Post
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 03-18-2014 , 05:44   Re: datatimer | :any parameter
Reply With Quote #5

Yep. Like @Master... said.

Do you really need global Handle array for store timers ??
And you don't need CloseHhandle datataimer datapack, it will do itself.

anyway...
Code:

Timer_ClientJoinedTeam[MAXPLAYERS+1];

Daa(client)
{

	if(Timer_ClientJoinedTeam[client] != INVALID_HANDLE)
	{
		KillTimer(Timer_ClientJoinedTeam[client]);
		Timer_ClientJoinedTeam[client] = INVALID_HANDLE;
	}

	new Handle:hJoinTeamInfo;
	Timer_ClientJoinedTeam[client] = CreateDataTimer(1.0, OnClientChangedTeam, hJoinTeamInfo);
	WritePackCell(hJoinTeamInfo, client);
	WritePackCell(hJoinTeamInfo, GetClientUserId(client));
	...
	...
	...
	...
	ResetPack(hDatapack);

}

public Action:OnClientChangedTeam(Handle:timer, Handle:hDatapack)
{
	new array_index = ReadPackCell(hDatapack);
	Timer_ClientJoinedTeam[array_index] = INVALID_HANDLE; // Clear handle when timer make (last) action.

	new client = GetClientOfUserId(ReadPackCell(hDatapack));

	if(client == 0)
	{
		return Plugin_Stop;
	}
	...
	...
	...
	...


	return Plugin_Continue;
}
Bacardi is offline