Checkpoint moved on player
#1

code:
Код:
if(strcmp(cmd, "/findman", true) == 0)
	{
	    tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /findman [playerid/PartOfName]");
				return 1;
			}
			giveplayerid = ReturnUser(tmp);
			if(IsPlayerConnected(giveplayerid))
			{
			  if(giveplayerid != INVALID_PLAYER_ID)
			  {
			    if(giveplayerid == playerid) { SendClientMessage(playerid, COLOR_GREY, "You cannot Find yourself!"); return 1; }
				  GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
					new Float:X,Float:Y,Float:Z;
					GetPlayerPos(giveplayerid, X,Y,Z);
					SetPlayerCheckpoint(playerid, X,Y,Z, 0);
					SetTimer("makav", 1000, 1);
				}
			}
			else
			{
			  SendClientMessage(playerid, COLOR_GREY, "  Invalid Name/ID !");
			}
    return 1;
  }
now i want to do, in timer the checkpoint move on the player.
how its need to be?
i do:
Код:
public makav(giveplayerid, playerid)
{
 for(new i = 0; i < MAX_PLAYERS; i++)
  {
	 new Folat:x, Folat:y, Folat:z;
	 GetPlayerPos(giveplayerid, x, y, z);
	 SetPlayerCheckpoint(playerid, x,y,z, 0);
	 return 1;
  }
}
but its do checkpoint on me!
what i need to do?
Reply
#2

Код:
SetPlayerCheckpoint(giveplayerid, X,Y,Z, 2);
Reply
#3

The timer function doesn't look right; redundancy checking will help (you already set the checkpoint in the command-line process, so why do it again in the timed process). Checkpoint Timer function should look at IsPlayerInCheckpoint() to understand its state. The clue to finding the answer is with your timer routine var(i).. your logic dictates its construction but you never use the index to player id (var i) in your code.

Quote:

for(new i = 0; i < MAX_PLAYERS; i++)
{
new Folat, Folat:y, Folat:z;
GetPlayerPos(giveplayerid, x, y, z);
SetPlayerCheckpoint(playerid, x,y,z, 0);
return 1;
}

Defined variables that are not used generally indicate a logical error.
Undefined variables, such as "giveplayerid" and "playerid" will result in several errors if they are not global.

Approach to checkpoint logic should look something like the snippet below; all the timer does is watch the checkpoint for each player.
Notice the public definition for my function? You must have a forward declaration for public functions in the precompiled section of the main code segment. SetTimer belongs in OnGameModeInit().

Код:
forward chkptimer();
..
SetTimer("chkptimer()",250,true);
..
public chkptimer()
{
  for(new idx=1;idx<=MAX_CHECKPOINTS;idx++)
  { for(new id=0;id<=MAX_PLAYERS;id++)
    { if(IsPlayerConnected(id))
      { if(IsPlayerInCheckpoint(id))
         { OnPlayerEnterCheckpoint(id,idx);} else {OnPlayerLeaveCheckpoint(id,idx);}
      }
    }
  }
}
You've already accomplished setting the checkpoint in the command-line process.
Your timer routine is not necessary and is overwriting the checkpoint you have set up in the actual slash-command.
Use the timer when you want to find out if a player is in the checkpoint.. or when they leave.

Reply
#4

hmm.. copyright infringement.. lets see if that holds up.. i am the man
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)