I got this cmd from some fs,and now when I go to plant weed I want that the player must be little away from the previsous one that is planted,I think some kind of the loop needs to be created that check if is player near the already planted,and if he does send him a message like "you are too close from another plant you cant plant here" please help if somebody know
pawn Code:
if(strcmp(cmd, "/sadidrogu", true) == 0 || strcmp(cmd, "/saditravu", true) == 0)
{
if (!PlayerInfo[playerid][pSeme]) return SendClientMessage(playerid, COLOR_GREY,"Nemate semenke!");
{
for(new weed = 0; weed < sizeof(WeedInfo); weed++)
{
if(!PlayerToPoint(20.0,playerid, 2454.8757,-564.7634,104.6606)) return SendClientMessage(playerid,COLOR_GREY,"Niste u zoni gde mozete saditi marihuanu!");
{
if(WeedInfo[weed][WeedPlanted] == 0 && WeedInfo[weed][WeedTime] == 0)
{
if(PlayerInfo[playerid][pLeader] == 15 || PlayerInfo[playerid][pMember] == 15 || PlayerInfo[playerid][pLeader] == 16 || PlayerInfo[playerid][pMember] == 16)
{
if (GetPlayerState(playerid) != PLAYER_STATE_ONFOOT) return SendClientMessage(playerid, COLOR_GRAD2, "Ne mozes sada saditi!");
if (GetPlayerInterior(playerid) != 0) return SendClientMessage(playerid, COLOR_GRAD2, "Ne mozes ovde saditi marihuanu!");
new Float:X,Float:Y,Float:Z;
GetPlayerPos(playerid, X, Y, Z);
GetPlayerName(playerid, playername, 24);
ApplyAnimation(playerid, "BOMBER","BOM_Plant",4.0,0,0,0,0,0);
weedObject[weed] = CreateObject(19473, X, Y, Z-2, 0, 0, 0);
Weeder[playerid] = 1200;
WeedInfo[weed][WeedX] = X;
WeedInfo[weed][WeedY] = Y;
WeedInfo[weed][WeedZ] = Z;
WeedInfo[weed][WeedTime] = 20;
WeedInfo[weed][WeedPlanted] = 1;
strmid(WeedInfo[weed][WeedPlanter], playername, 0, strlen(playername), 50);
SendClientMessage(playerid,COLOR_FADE1,"Posadili ste marihuanu, sacekajte da naraste pa je uberite!");
//SendClientMessage(playerid,COLOR_FADE1,"Remember to type /pickweed Before someone else takes your weed!");
PlayerInfo[playerid][pSeme] -= 1;
WATER[playerid] -= 1;
return 1;
}
}
}
}
}
}
Maybe try to set if is player in range point? Like multiple range points with concrete location...
pawn Code:
if(IsPlayerInRangeOfPoint(playerid,20.0,WeedInfo[weed][WeedX],WeedInfo[weed][WeedY],WeedInfo[weed][WeedZ])) return SendClientMessage(playerid,-1,"ERROR: You can't plant more weed here.");
Just loop through all the plants and check if the player is in range of any of them.