Another Problem
#1

This is my code for the dm event system:

Код:
public AtriDmStartTime()
{
	new string[30];
	DmEventCountDown--;

	if(DmEventCountDown == 30)
	{
		SendClientMessageToAll(0x00FF00FF, "[EVENT]: {FFFFFF}Only 30 seconds left, /join before event starts.");
	}
	for(new i = 0; i < MAX_PLAYERS; i++)
	{
		if(IsPlayerConnected(i))
		{

	    	if(IsPlayerInEvent[i] == true)
	    	{
				if(DmEventCountDown > 0)
				{
					format(string, sizeof(string), "Time Left: %d", DmEventCountDown);
	    			GameTextForPlayer(i, string, 5000, 3);
				}
				else if(DmEventCountDown == 0)
				{
					if(PlayersJoinedEvent <= 1)
					{
						SendClientMessageToAll(0xFF0000AA, "[EVENT]: {FFFFFF}The event has been cancled, Not enough players!");
						IsPlayerInEvent[i] = false;
					 	PlayersJoinedEvent = 0;
						AtriDM = 0;
					 	SetPlayerHealth(i, 0);
						DmEventCountDown = 60;
		   				SetPlayerInterior(i, 0);
						DmEventTimerVar = SetTimer("DmEventT", 1800000, false);
						KillTimer(Event1SecT);
					}
					else if(PlayersJoinedEvent > 1 && IsPlayerInEvent[i] == true)
					{
						SendClientMessage(i, 0x00FF00AA, "[EVENT]: {FFFFFF}You have been unfrozen, be the last man standing to win the prize!");
		                TogglePlayerControllable(i,1);      
				    	GameTextForPlayer(i, "~w~Event ~g~Started", 5000, 3);
						DmEventCountDown = 60;
						AtriDM = 2;
						KillTimer(Event1SecT);
					}
				}
			}
		}
	}
	return 1;
}
Thing here is, it doesn't unfreeze players.
Reply
#2

Why MAX_PLAYER loop in 2017?
PHP код:
for(new i = 0; i < MAX_PLAYERS; i++) 
How is this function called?
PHP код:
AtriDmStartTime() 
Use [PHP] tags for code, it makes the code more readable.

Use proper naming for functions and variables, I mentioned this in your deleted thread.

Be independent, debug your code by adding a small message in the part where it should unfreeze you, if the message is not sent, this means that part is not being called.
Reply
#3

Dude don't delete the thread even if u got the help i was also typing a longass reply there its rude...
also show these :
PHP код:
PlayersJoinedEvent > 1 && IsPlayerInEvent[i] == true 
where are u doing PlayersJoinedEvent++; and the IsPLayerInEvent[playerid] =true;
Reply
#4

AtriDmStartTime()

PHP код:
public DmEventT()
{
    
SendClientMessageToAll(0x00FFFFAA, "[EVENT]: {FFFFFF}Atrium deathmatch event has started, type /join to take part!");
    
AtriHealthPickup[0] = CreateDynamicPickup(1240, 2, 1728.2104,-1668.2876,22.6094, -1, 18, -1, 100.0);
    
AtriHealthPickup[1] = CreateDynamicPickup(1240, 2, 1701.4614,-1648.4786,20.2194, -1, 18, -1, 100.0);
    
AtriArmourPickup[0] = CreateDynamicPickup(1242, 2, 1734.8628,-1639.2264,20.2307, -1, 18, -1, 100.0);
    
AtriArmourPickup[0] = CreateDynamicPickup(1242, 2, 1708.9303,-1677.3439,27.2016, -1, 18, -1, 100.0);
    
AtriAdrenalinePickup = CreateDynamicPickup(1241, 2, 1721.5195,-1672.7142,20.2234, -1, 18, -1, 100.0);
    
Event1SecT = SetTimer("AtriDmStartTime", 1000, true);
    
KillTimer(DmEventTimerVar);
    
AtriDM = 1;
    return 
1;
} 
PHP код:
CMD:forcetevent(playerid, parmas)
{
    if(
PInfo[playerid][Admin] < 3) return SendClientMessage(playerid, RED,"[ERROR]: {FFFFFF}You do not have the privilleges to perform this command.");

    
DmEventT();
    return 
1;
} 
I read what you said, I deleted that thread because it was a common mistake and i was just being stupid. Though I will rewrite my code sometime in the near future. I hope you could help me with this.
Reply
#5

PHP код:
forward DeathMatchStarter();
public 
DeathMatchStarter()
{
    
gDMCountdown -= 1;
    if(
gDMCountdown)
    {
        if(
gDMCountdown == 30) //SendClientMessageToAll()
        
new str[30];
        
format(str, sizeof str, "Time left: %d", gDMCountdown);
        
//GameTextForAll
    
}
    else
    {
        if(!
gDMPlayers) // if players didnt join
        
{
            
SendClientMessageToAll(0xFF0000AA, "[EVENT]: {FFFFFF}The event has been cancled, Not enough players!");
            foreach(new 
i : Player)
            {
                
IsPlayerInEvent[i] = false;
                
PlayersJoinedEvent = 0;
                
AtriDM = 0;
                
SetPlayerHealth(i, 0);
                
DmEventCountDown = 60;
                
SetPlayerInterior(i, 0);
                
DmEventTimerVar = SetTimer("DmEventT", 1800000, false);
                
KillTimer(Event1SecT);
            }
        }
        else  
// If players joined the event
        
{
            foreach(new 
i : Player)
            {
                
// code
            
}
        }
    }
    return 
1;
} 
Your code should look something like this.

Again, if you're doing something, do it right from the start, not from the middle!

EDIT:

Mistake:
PHP код:
    AtriArmourPickup[0] = CreateDynamicPickup(1242, 2, 1734.8628,-1639.2264,20.2307, -1, 18, -1, 100.0); 
    
AtriArmourPickup[0] = CreateDynamicPickup(1242, 2, 1708.9303,-1677.3439,27.2016, -1, 18, -1, 100.0); 
Shouldn't it be...
PHP код:
    AtriArmourPickup[0] = CreateDynamicPickup(1242, 2, 1734.8628,-1639.2264,20.2307, -1, 18, -1, 100.0); 
    
AtriArmourPickup[1] = CreateDynamicPickup(1242, 2, 1708.9303,-1677.3439,27.2016, -1, 18, -1, 100.0); 
Reply
#6

Quote:
Originally Posted by RogueDrifter
Посмотреть сообщение
Dude don't delete the thread even if u got the help i was also typing a longass reply there its rude...
also show these :
PHP код:
PlayersJoinedEvent > 1 && IsPlayerInEvent[i] == true 
where are u doing PlayersJoinedEvent++; and the IsPLayerInEvent[playerid] =true;
Oh, I'm really sorry. Won't happen again.
Reply
#7

Quote:
Originally Posted by Uvais
Посмотреть сообщение
AtriDmStartTime()

PHP код:
public DmEventT()
{
    
SendClientMessageToAll(0x00FFFFAA, "[EVENT]: {FFFFFF}Atrium deathmatch event has started, type /join to take part!");
    
AtriHealthPickup[0] = CreateDynamicPickup(1240, 2, 1728.2104,-1668.2876,22.6094, -1, 18, -1, 100.0);
    
AtriHealthPickup[1] = CreateDynamicPickup(1240, 2, 1701.4614,-1648.4786,20.2194, -1, 18, -1, 100.0);
    
AtriArmourPickup[0] = CreateDynamicPickup(1242, 2, 1734.8628,-1639.2264,20.2307, -1, 18, -1, 100.0);
    
AtriArmourPickup[0] = CreateDynamicPickup(1242, 2, 1708.9303,-1677.3439,27.2016, -1, 18, -1, 100.0);
    
AtriAdrenalinePickup = CreateDynamicPickup(1241, 2, 1721.5195,-1672.7142,20.2234, -1, 18, -1, 100.0);
    
Event1SecT = SetTimer("AtriDmStartTime", 1000, true);
    
KillTimer(DmEventTimerVar);
    
AtriDM = 1;
    return 
1;
} 
PHP код:
CMD:forcetevent(playerid, parmas)
{
    if(
PInfo[playerid][Admin] < 3) return SendClientMessage(playerid, RED,"[ERROR]: {FFFFFF}You do not have the privilleges to perform this command.");
    
DmEventT();
    return 
1;
} 
I read what you said, I deleted that thread because it was a common mistake and i was just being stupid. Though I will rewrite my code sometime in the near future. I hope you could help me with this.
Uhm... show the /join command... make sure that you're doing what i said in my previous comment (PlayersJoined++ and IsPlayerInEvent=true)
Reply
#8

PHP код:
CMD:join(playerid, parmas)
{
    if(
AtriDM == 0) return SendClientMessage(playerid, 0xFF0000AA, "[EVENT]: {FFFFFF}No event started yet!");
    if(
IsPlayerInEvent[playerid] == true) return SendClientMessage(playerid, 0xFF0000AA, "[EVENT]: {FFFFFF}You already joined the event be patience the event will start soon!");
    if(
AtriDM == 2) return SendClientMessage(playerid, 0xFF0000AA, "[EVENT]: {FFFFFF}This event already begun you cant join now!");

    new 
Random = random(sizeof(AtriSpawns)), string[128];
    
SetPlayerPos(playerid, AtriSpawns[Random][0], AtriSpawns[Random][1], AtriSpawns[Random][2]);
    
SetPlayerFacingAngle(playerid, AtriSpawns[Random][3]);
    
SetPlayerInterior(playerid, 18);
    
SetCameraBehindPlayer(playerid);
    
TogglePlayerControllable(playerid, 0);
    
SendClientMessage(playerid, 0x00FF00AA, "[EVENT]: {FFFFFF}You have joined Atrium deathmatch event!");
    
format(string, sizeof(string), "[EVENT]: {FFFFFF}%s has joined the dm event, Type /join to enter it!", GetName(playerid));
    
SendClientMessageToAll(0x00FF00AA, string);
    
IsPlayerInEvent[playerid] = true;
    
PlayersJoinedEvent++;
    
ResetPlayerWeapons(playerid);
    
PlayerClass[playerid] = 0;
    
ChosenClass[playerid] = 0;
    
SetPlayerSkin(playerid, 294);
    
SetPlayerColor(playerid, 0xFFFFFFFF);
    
SetPlayerTeam(playerid, TEAM_NONE);
    
GivePlayerWeapon(playerid, 31, 100);
    
GivePlayerWeapon(playerid, 24, 50);
    
GivePlayerWeapon(playerid, 27, 40);
    
GivePlayerWeapon(playerid, 34, 10);
    
GivePlayerWeapon(playerid, 16, 1);
    return 
1;
} 
Reply
#9

Take a look at my previous reply, your command looks fine.
Reply
#10

Quote:
Originally Posted by Logic_
Посмотреть сообщение
Take a look at my previous reply, your command looks fine.
Thanks, I have fixed that but the problem is still not resolved.
Reply


Forum Jump:


Users browsing this thread: