if(strcmp(cmd,"/plantweed",true)==0)
{
if(IsPlayerConnected(playerid))
{
if (PlayerInfo[playerid][pJob] != 4)
{
SendClientMessage(playerid,COLOR_GREY, "You are not a Drug Dealer !");
return 1;
}
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
if(GetPlayerState(playerid) != 1) return SendClientMessage(playerid, COLOR_GREY, " You must be on foot !");
if(GetPlayerInterior(playerid) > 0) return SendClientMessage(playerid, COLOR_GREY, " You must be outside to plant your seeds.");
if(PlayerInfo[playerid][pSeeds] == 0) return SendClientMessage(playerid, COLOR_GREY, " You don't have any Seeds!");
if(PlayerInfo[playerid][pSeeds] < 10) return SendClientMessage(playerid, COLOR_GREY, " You don't have enough Seeds!");
if(HasPlantWeed[playerid] == 1) return SendClientMessage(playerid, COLOR_GRAD2, "* You have already planted a weed !");
new Float:X, Float:Y, Float:Z;
ApplyAnimation(playerid, "BOMBER", "BOM_Plant", 4.0, 0, 0, 0, 0, 0);
GetPlayerPos(playerid, X, Y, Z);
Weed_x[playerid] = X;
Weed_y[playerid] = Y;
Weed_z[playerid] = Z;
Weed[playerid] = CreateDynamicObject(3409, X, Y, Z-1.8, 0, 0, 0);
HasPlantWeed[playerid] = 1;
PlayerInfo[playerid][pSeeds] -= 10;
format(string, sizeof(string), "* %s plants some seeds.", name);
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
SendClientMessage(playerid, COLOR_GREEN, "You have planted your seeds! Every minute, your plant will make one gram of weed.");
SendClientMessage(playerid, COLOR_GREEN, "If your plant won't picked within 70 minutes, it will rot and you will lose it.");
SendClientMessage(playerid, COLOR_GREEN, "Also remember that anyone can /pickweed if they find your plant, so be careful.");
}
return 1;
}
if(strcmp(cmd,"/plantweed",true)==0)
{
if(IsPlayerConnected(playerid))
if(HasPlantWeed[playerid] == 1) return SendClientMessage(playerid, COLOR_GRAD2, "* You have already planted a weed !"); new Float:X, Float:Y, Float:Z; ApplyAnimation(playerid, "BOMBER", "BOM_Plant", 4.0, 0, 0, 0, 0, 0); GetPlayerPos(playerid, X, Y, Z); Weed_x[playerid] = X; Weed_y[playerid] = Y; Weed_z[playerid] = Z; Weed[playerid] = CreateDynamicObject(3409, X, Y, Z-1.8, 0, 0, 0); HasPlantWeed[playerid] = 1;
#define MAX_WEED_PLANTS 5
#define WEED_Z_OFFSET -1.8
enum WEEDENUM {
WeedObj[MAX_WEED_PLANTS],
Float:Weed_x[MAX_WEED_PLANTS],
Float:Weed_y[MAX_WEED_PLANTS],
Float:Weed_z[MAX_WEED_PLANTS]
}
new WeedData[MAX_PLAYERS][WEEDENUM]
for(new i = 0; i < MAX_PLAYERS; i++)
{
for(new j = 0; j < MAX_WEED_PLANTS; j++) { WeedData[i][WeedObj][j] = INVALID_OBJECT_ID; }
}
AddWeedPlant(playerid)
{
// Find a open plant slot
for(new i = 0; i < MAX_WEED_PLANTS; i++)
{
if(WeedData[playerid][WeedObj][i] == INVALID_OBJECT_ID)
{
ApplyAnimation(playerid, "BOMBER", "BOM_Plant", 4.0, 0, 0, 0, 0, 0);
GetPlayerPos(playerid, WeedData[playerid][Weed_x], WeedData[playerid][Weed_y], WeedData[playerid][Weed_z]);
WeedData[playerid][Weed_z] += WEED_Z_OFFSET;
Weed[playerid] = CreateDynamicObject(3409, WeedData[playerid][Weed_x], WeedData[playerid][Weed_y], WeedData[playerid][Weed_z], 0, 0, 0);
return 1;
}
}
return 0;
}
DestroyWeedPlant(playerid, index)
{
if(WeedData[playerid][WeedObj][i] != INVALID_OBJECT_ID)
{
DestroyDynamicObject(WeedData[playerid][WeedObj][i]);
WeedData[playerid][WeedObj][i] = INVALID_OBJECT_ID;
return 1;
}
return 0;
}
if(strcmp(cmd,"/plantweed",true)==0)
{
if (PlayerInfo[playerid][pJob] != 4) return SendClientMessage(playerid,COLOR_GREY, "You are not a Drug Dealer !");
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
if(GetPlayerState(playerid) != 1) return SendClientMessage(playerid, COLOR_GREY, " You must be on foot !");
if(GetPlayerInterior(playerid) > 0) return SendClientMessage(playerid, COLOR_GREY, " You must be outside to plant your seeds.");
if(PlayerInfo[playerid][pSeeds] == 0) return SendClientMessage(playerid, COLOR_GREY, " You don't have any Seeds!");
if(PlayerInfo[playerid][pSeeds] < 10) return SendClientMessage(playerid, COLOR_GREY, " You don't have enough Seeds!");
if(!AddWeedPlant(playerid)) return SendClientMessage(playerid, COLOR_GRAD2, "* You have the maximum plants planted !");
PlayerIfo[playerid][pSeeds] -= 10;
format(string, sizeof(string), "* %s plants some seeds.", name);
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
SendClientMessage(playerid, COLOR_GREEN, "You have planted your seeds! Every minute, your plant will make one gram of weed.");
SendClientMessage(playerid, COLOR_GREEN, "If your plant won't picked within 70 minutes, it will rot and you will lose it.");
SendClientMessage(playerid, COLOR_GREEN, "Also remember that anyone can /pickweed if they find your plant, so be careful.");
return 1;
}
if(HasPlantWeed[playerid] == 1) return SendClientMessage(playerid, COLOR_GRAD2, "* You have already planted a weed !");
HasPlantWeed[playerid] = 1;
HasPlantedWeed[playerid]++;
Remember other commands like /pickweed will need to be updated, you need to take into account when a player disconnects saving the data. There is still probably a bunch more to update but hopefully this sets you on the right direction. |