31.07.2016, 07:05
https://sampforum.blast.hk/showthread.php?tid=609790
I download that filterscript and I want to make /plant harvest is only allowed for your plant only,how do i do that?
the command
I download that filterscript and I want to make /plant harvest is only allowed for your plant only,how do i do that?
the command
PHP Code:
COMMAND:plant(playerid, params[])
{
if(IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, 0xE74C3CFF, "ERROR: {FFFFFF}You can't use this command in a vehicle.");
if(isnull(params)) return SendClientMessage(playerid, 0xE88732FF, "SYNTAX: {FFFFFF}/plant [place/harvest]");
if(!strcmp(params, "place", true)) {
/* -- planting -- */
if(Player[playerid][InDrugZone] == false) return SendClientMessage(playerid, 0xE74C3CFF, "ERROR: {FFFFFF}You aren't in drug zone.");
if(PlayerDrugData[playerid][Seeds] < 1) return SendClientMessage(playerid, 0xE74C3CFF, "ERROR: {FFFFFF}You don't have a drug seed.");
if(Player_PlantCount(playerid) >= PLAYER_LIMIT) return SendClientMessage(playerid, 0xE74C3CFF, "ERROR: {FFFFFF}You can't plant any more drug plants.");
if(GetClosestPlant(playerid) != -1) return SendClientMessage(playerid, 0xE74C3CFF, "ERROR: {FFFFFF}You can't place a drug plant here because there is one nearby.");
new id = Iter_Free(Plants);
if(id == -1) return SendClientMessage(playerid, 0xE74C3CFF, "ERROR: {FFFFFF}Server drug plant limit reached.");
GetPlayerName(playerid, PlantData[id][plantedBy], MAX_PLAYER_NAME);
GetPlayerPos(playerid, PlantData[id][plantX], PlantData[id][plantY], PlantData[id][plantZ]);
PlantData[id][plantGrowth] = 0;
PlantData[id][plantObj] = CreateDynamicObject(3409, PlantData[id][plantX], PlantData[id][plantY], PlantData[id][plantZ] - 0.75, 0.0, 0.0, 0.0);
SetDynamicObjectMaterial(PlantData[id][plantObj], 2, 19478, "signsurf", "sign", 0xFFFFFFFF);
new label_string[128];
format(label_string, sizeof(label_string), "Drug Plant (%d)\n\n{FFFFFF}Placed by %s\nGrowth: {E74C3C}0%%\n\n{FFFFFF}/plant harvest", id, PlantData[id][plantedBy]);
PlantData[id][plantLabel] = CreateDynamic3DTextLabel(label_string, 0xF1C40FFF, PlantData[id][plantX], PlantData[id][plantY], PlantData[id][plantZ], 5.0);
PlantData[id][plantTimer] = SetTimerEx("PlantGrowth", GROWTH_INTERVAL * 1000, true, "i", id);
Iter_Add(Plants, id);
PlayerDrugData[playerid][Seeds]--;
PlayerDrugData[playerid][TotalPlanted]++;
/* -- planting -- */
}else if(!strcmp(params, "harvest")) {
/* -- harvesting -- */
if(PlayerDrugData[playerid][Drugs] >= CARRY_LIMIT) return SendClientMessage(playerid, 0xE74C3CFF, "ERROR: {FFFFFF}You can't carry any more drugs.");
new id = GetClosestPlant(playerid);
if(id == -1) return SendClientMessage(playerid, 0xE74C3CFF, "ERROR: {FFFFFF}You're not near a drug plant.");
if(!PlantData[id][gotLeaves]) return SendClientMessage(playerid, 0xE74C3CFF, "ERROR: {FFFFFF}You can't harvest this plant because it's not ready.");
new harvested = PlantData[id][plantGrowth], string[96];
if(PlayerDrugData[playerid][Drugs] + harvested > CARRY_LIMIT) harvested = CARRY_LIMIT - PlayerDrugData[playerid][Drugs];
format(string, sizeof(string), "DRUG PLANT: {FFFFFF}You harvested a drug plant and got %d grams of drugs.", harvested);
SendClientMessage(playerid, 0x3498DBFF, string);
PlayerDrugData[playerid][Drugs] += harvested;
PlayerDrugData[playerid][TotalHarvestedPlants]++;
PlayerDrugData[playerid][TotalHarvestedGrams] += harvested;
new owner_id = Plant_GetOwnerID(id);
if(strcmp(PlantData[id][plantedBy], Player_GetName(playerid), true) && IsPlayerConnected(owner_id)) SendClientMessage(owner_id, 0x3498DBFF, "DRUG PLANT: {FFFFFF}Somebody harvested one of your drug plants!");
Plant_Destroy(id);
/* -- harvesting -- */
}else{
SendClientMessage(playerid, 0xE88732FF, "SYNTAX: {FFFFFF}/plant [place/harvest]");
}
return 1;
}