16.10.2014, 10:25
Hi,
I was making a Drug system and wished that I can in cmd /plant make x, y, z postion that I will use in /harvest too for making IsPlayerInRangeOfPoint. Please help me with it. I tried with GetObjectPos but I failed with objectid
I was making a Drug system and wished that I can in cmd /plant make x, y, z postion that I will use in /harvest too for making IsPlayerInRangeOfPoint. Please help me with it. I tried with GetObjectPos but I failed with objectid
pawn Код:
CMD:plant(playerid, params[])
{
if(PlayerInfo[playerid][drugseeds] > 0)
{
if(PlayerInfo[playerid][atimers] < 4)
{
if(IsPlayerInAnyVehicle(playerid)) SendClientMessage(playerid, 0x00FF00AA, "You're in a vehicle.");
if(IsPlayerInInterior(playerid)) SendClientMessage(playerid, -1, "You can't plant in interiors!");
else
{
new Float:X, Float:Y, Float:Z;
GetPlayerPos(playerid, X, Y, Z);
SetPVarInt(playerid, "Drugbush",CreateObject(3409, X, Y, Z-1, 0.0, 0.0, 0.0));
PlayerInfo[playerid][drugseeds] -= 1;
SetTimer("PlantDrugs", 300000, false);
PlayerInfo[playerid][planted] += 1;
PlayerInfo[playerid][atimers] += 1;
SendClientMessage(playerid, -1, "You spended 1 drug seed! Your drug will grow for 5 minutes, so come when it growns up and type /harvest!");
}
}
else return SendClientMessage(playerid, -1, "You can plant max 4 drug seeds!");
}
else return SendClientMessage(playerid, -1, "You don't have enough drug seeds(1 required)! You can buy it in drug house!");
return 1;
}
forward PlantDrugs(playerid);
public PlantDrugs(playerid)
{
PlayerInfo[playerid][atimers] -= 1;
SendClientMessage(playerid, -1, "Your drug growned! You can now harvest it!");
return 1;
}
CMD:harvest(playerid, params[])
{
new Float:X, Float:Y, Float:Z;
GetObjectPos(strval("Drugbush"), X, Y, Z);
if(PlayerInfo[playerid][atimers] < 4)
{
if(PlayerInfo[playerid][planted] > (PlayerInfo[playerid][atimers]))
{
if(IsPlayerInAnyVehicle(playerid)) SendClientMessage(playerid, 0x00FF00AA, "You're in a vehicle.");
if(IsPlayerInRangeOfPoint(playerid, 4.0, X, Y, Z))
{
ApplyAnimation(playerid,LIBRARY,ANIMATION,4.1,false,false,false,false,3000,false);
DestroyObject(GetPVarInt(playerid, "Drugbush"));
PlayerInfo[playerid][drugs] += 4;
PlayerInfo[playerid][planted] -= 1;
SendClientMessage(playerid, -1, "You harvested your drug bush and got 4 grams of drugs!");
}
if(!IsPlayerInRangeOfPoint(playerid, 4.0, X, Y, Z))
{
SendClientMessage(playerid, -1, "You aren't near your drug bush!");
}
}
else
{
SendClientMessage(playerid, -1, "You didn't plant any drug seeds or it didn't grown up!");
}
}
else
{
SendClientMessage(playerid, -1, "You didn't plant any drug seeds or it didn't grown up!");
}
return 1;
}