Freezing problem
#1

Wow this post + my last one make me seem like a noob >.<

Anyway this post is about a timer etc. I made that doesn't want to work. The point of it is to check a players position every second, and if they are near a trap that has been laid by the other team, than they are frozen but, this is not working. Here is the code

Код:
forward MagTimer(playerid);


public MagTimer(playerid)
{
 	for(new i = 0; i < MAX_PLAYERS; i++)
	{
		if(Xmag[i] != 255 && Ymag[i] != 255 && Zmag[i] != 255 && PlayerToPoint(2.0,i,Xmag[i],Ymag[i],Zmag[i]))
		{
			if (gTeam[playerid] == TEAM_SEAK)
		    {
				TogglePlayerControllable(playerid,0);
				Xmag[i] = 255;
				Ymag[i] = 255;
				Zmag[i] = 255;
				return 1;
			}
		}
	}
	return 0;
}


public OnPlayerSpawn(playerid)
{
    if (gTeam[playerid] == TEAM_SEAK)
	{
	  SetTimer("MagTimer",1000,1);
	  SetPlayerToTeamColor(playerid);
      return 1;
     }
     return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
	new Float:x, Float:y, Float:z;
	if(strcmp(cmdtext,"/trap",true) ==0)
	{
		if (gTeam[playerid] == TEAM_SNEAK)
		{
	  	    if(Mag[playerid] == 0)
	  	    {
				Mag[playerid] = 1;
				GetPlayerPos(playerid,x,y,z);
	  		    Xmag[playerid] = x;
   			    Ymag[playerid] = y;
    		    Zmag[playerid] = z;
	  		    SetPlayerMapIcon(playerid,1,x,y,z,61,COLOR_YELLOW);
	  		    ApplyAnimation(playerid,"BOMBER","BOM_Plant",1,0,0,0,0,2000);
    			    CreateObject(2824,x,y,18.7,0,0,0);
	  		    SendClientMessage(playerid,COLOR_BLUE,"You have placed a magazine. It will distract anyone that walks by it. You have 1 mag remaining!");
				return 1;
	  	    }
Blah blah
Reply
#2

Hmmm it still doesn't work right :/
Reply
#3

Try

pawn Код:
SetTimerEx("MagTimer",1000,1,"i",playerid);
Reply
#4

No its weird cause it worked earlier but ofc I changed something and it fucked up the Mag shit and I didn't pay attention to it and now here I am lol. The SetTimerEx still didn't work. Im thinking it has something to do with retrieving the coords of the placed trap.

Edit: Ok its doing what it did about 30 minutes ago. When I spawn, my player randomly freezes every second for a second as if he was in a trap even though he isn't >.<
Reply
#5

Try replacing
pawn Код:
if(Xmag[i] != 255 && Ymag[i] != 255 && Zmag[i] != 255 && PlayerToPoint(2.0,i,Xmag[i],Ymag[i],Zmag[i]))
with
pawn Код:
if(Xmag[i] != 255 && Ymag[i] != 255 && Zmag[i] != 255 && PlayerToPoint(2.0,playerid,Xmag[i],Ymag[i],Zmag[i]))
Reply
#6

Quote:
Originally Posted by player007
Try replacing
pawn Код:
if(Xmag[i] != 255 && Ymag[i] != 255 && Zmag[i] != 255 && PlayerToPoint(2.0,i,Xmag[i],Ymag[i],Zmag[i]))
with
pawn Код:
if(Xmag[i] != 255 && Ymag[i] != 255 && Zmag[i] != 255 && PlayerToPoint(2.0,playerid,Xmag[i],Ymag[i],Zmag[i]))
Dude your awesome. I works for the most part, just a few small bugs I have to fix but thanks you did the hard part
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)