Check if player2 is in player1 checkpoint HOW?
#1

How to do this?

How to check if player2 or player3..... is in player1 checkpoint?
Reply
#2

If player2 or player3 are on checkpoint or if they are near player1? I can't understand you question
Reply
#3

https://sampforum.blast.hk/showthread.php?tid=251483
Reply
#4

@If player2 or player3 are on checkpoint or if they are near player1? I can't understand you question

When they enter in checkpoint created by player1.
Reply
#5

I don't know how to use this: https://sampforum.blast.hk/showthread.php?tid=251483

Please for a basic example code.
Reply
#6

I assume that you know already the coordinates of the checkpoint that you want to check if the player is in range of. Use
pawn Код:
IsPlayerInRangeOfPoint(playerid, Float:range, Float:x, Float:y, Float:z)
I hope I helped any feedback is appreciated!
Reply
#7

Quote:
Originally Posted by dan40o
Посмотреть сообщение
When they enter in checkpoint created by player1.
Its not tested, I had some other code similar to it for some test, hope it works.
Код:
#include <a_samp>
#include <zcmd>
#include <streamer>
#include <sscanf2>

new PlayerName[MAX_PLAYERS][MAX_PLAYER_NAME];
new CP_Maker[MAX_PLAYERS][30];
new CheckPoint;
CMD:createcp(playerid,params[])
{
 	new pID, pTYPE;
	if(sscanf(params, "dd", pID, pTYPE)) return SendClientMessage(playerid, -1, "USAGE: {999999}/createcp");
	new Float:pos[3];
	GetPlayerPos(playerid,pos[0],pos[1],pos[2]);
	new pVW = GetPlayerVirtualWorld(playerid);
	new pIntID = GetPlayerInterior(playerid);
	CheckPoint = CreateDynamicCP(pos[0],pos[1],pos[2],10, pVW, pIntID, -1, 100);
	format(CP_Maker[playerid],MAX_PLAYER_NAME,"%s",Name(playerid));
	return 1;
}
public OnPlayerEnterDynamicCP(playerid, checkpointid)
{
    if(checkpointid == CheckPoint)
    {
	    new str[100];
	    format(str,sizeof(str),"{999999}This Checkpoint was created by {CBACBA}%s",CP_Maker[playerid]);
		SendClientMessage(playerid, -1, str);
    }
    return 1;
}
stock Name(playerid)
{
	GetPlayerName(playerid,PlayerName[playerid],MAX_PLAYER_NAME);
	new string[64];
	format(string, 64, "%s[%d]", PlayerName[playerid],playerid);
	return string;
}
And if i am wrong anywhere, Please correct me (:
Reply
#8

I am creating checkpoint:

Код:
CMD:plant(playerid, params[])
{
	if(planted_weed[playerid] == false)
	{
		if(PlayerInfo[playerid][WeedSeeds] >= 1)
		{
		    if(!IsPlayerInAnyVehicle(playerid))
		    {
				switch(random(2))
				{
					case 1:
					{
						planted_weed[playerid] = true;
						weedid[playerid] = playerid;
						PlayerInfo[playerid][WeedSeeds]--;
						SendClientMessage(playerid, GREEN, "Weed seeds were planted successfully.");
						weedtimer[playerid] = SetTimerEx("GrowingWeed", 18000, true, "i", playerid);
						GetPlayerPos(playerid, wX[playerid], wY[playerid], wZ[playerid]);
						GetPlayerName(playerid, weedname[playerid], MAX_PLAYERS);
						CheckPointplantweed[playerid] = CreateDynamicCP(wX[playerid], wY[playerid], wZ[playerid], 1.2, -1, -1, -1, 50.0);
						weedtext[playerid] = CreateDynamic3DTextLabel(weedname[playerid], WHITE, wX[playerid], wY[playerid], wZ[playerid], 20);

					}
					default:
					{
						PlayerInfo[playerid][WeedSeeds]--;
						SendClientMessage(playerid, RED, "Failed to plant the weed seeds.");
					}
				}
            }
			else  SendClientMessage(playerid,RED,"You can't plant your seeds while you're in a vehicle!");
		}
		else SendClientMessage(playerid, RED, "You don't have enough weed seeds!");
	}
	else SendClientMessage(playerid, RED, "You already have a growing seeds. You can have only 1 growing seeds from each plant!");
	return 1;
}
Check if other player enter in the checkpoint

Код:
if(checkpointid == CheckPointplantweed[playerid])
	{
	    if(weedid[playerid] == playerid)
		{
			SendClientMessage(playerid, YELLOW, "SERVER: Use /harvest to take your planted weed.");
			new strr[128];
			format(strr, sizeof(strr), "%d grams weed", growingweed[playerid]);
			GameTextForPlayer(playerid, strr, 200, 0);
		}
		else SendClientMessage(playerid, YELLOW, "SERVER: Use /steal to steal someone's weed."); // this doesn't work i don't know why. When other player enter nothing happens.
		return 1;
	}
I wanna make /steal command to steal the drugs but i don't know how to check if other player is in the checkpoint.
Reply
#9

Код:
if(checkpointid == CheckPointplantweed[playerid])
	{
	    if(weedid[playerid] == playerid)
		{
			if(planted_weed[playerid] == true)// added
			{
				SendClientMessage(playerid, YELLOW, "SERVER: Use /harvest to take your planted weed.");
				new strr[128];
				format(strr, sizeof(strr), "%d grams weed", growingweed[playerid]);
				GameTextForPlayer(playerid, strr, 200, 0);
			}else SendClientMessage(playerid, YELLOW, "SERVER: Use /steal to steal someone's weed."); // this doesn't work i don't know why. When other player enter nothing happens.
		}
	}
Reply
#10

Doesn't work.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)