drug system help
#1

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?

/plant cmd
PHP код:
COMMAND:plant(playeridparams[])
{
    if(
IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid0xE74C3CFF"ERROR: {FFFFFF}You can't use this command in a vehicle.");
    if(
isnull(params)) return SendClientMessage(playerid0xE88732FF"SYNTAX: {FFFFFF}/plant [place/harvest]");
    if(!
strcmp(params"place"true)) {
        
/* -- planting -- */
        
if(Player[playerid][InDrugZone] == false) return SendClientMessage(playerid0xE74C3CFF"ERROR: {FFFFFF}You aren't in drug zone.");
        if(
PlayerDrugData[playerid][Seeds] < 1) return SendClientMessage(playerid0xE74C3CFF"ERROR: {FFFFFF}You don't have a drug seed.");
        if(
Player_PlantCount(playerid) >= PLAYER_LIMIT) return SendClientMessage(playerid0xE74C3CFF"ERROR: {FFFFFF}You can't plant any more drug plants.");
        if(
GetClosestPlant(playerid) != -1) return SendClientMessage(playerid0xE74C3CFF"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(playerid0xE74C3CFF"ERROR: {FFFFFF}Server drug plant limit reached.");
        
GetPlayerName(playeridPlantData[id][plantedBy], MAX_PLAYER_NAME);
        
GetPlayerPos(playeridPlantData[id][plantX], PlantData[id][plantY], PlantData[id][plantZ]);
        
PlantData[id][plantGrowth] = 0;
        
PlantData[id][plantObj] = CreateDynamicObject(3409PlantData[id][plantX], PlantData[id][plantY], PlantData[id][plantZ] - 0.750.00.00.0);
        
SetDynamicObjectMaterial(PlantData[id][plantObj], 219478"signsurf""sign"0xFFFFFFFF);
        new 
label_string[128];
        
format(label_stringsizeof(label_string), "Drug Plant (%d)\n\n{FFFFFF}Placed by %s\nGrowth: {E74C3C}0%%\n\n{FFFFFF}/plant harvest"idPlantData[id][plantedBy]);
        
PlantData[id][plantLabel] = CreateDynamic3DTextLabel(label_string0xF1C40FFFPlantData[id][plantX], PlantData[id][plantY], PlantData[id][plantZ], 5.0);
        
PlantData[id][plantTimer] = SetTimerEx("PlantGrowth"GROWTH_INTERVAL 1000true"i"id);
        
Iter_Add(Plantsid);
        
PlayerDrugData[playerid][Seeds]--;
        
PlayerDrugData[playerid][TotalPlanted]++;
        
/* -- planting -- */
    
}else if(!strcmp(params"harvest")) {
        
/* -- harvesting -- */
        
if(PlayerDrugData[playerid][Drugs] >= CARRY_LIMIT) return SendClientMessage(playerid0xE74C3CFF"ERROR: {FFFFFF}You can't carry any more drugs.");
        new 
id GetClosestPlant(playerid);
        if(
id == -1) return SendClientMessage(playerid0xE74C3CFF"ERROR: {FFFFFF}You're not near a drug plant.");
        if(!
PlantData[id][gotLeaves]) return SendClientMessage(playerid0xE74C3CFF"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_LIMITharvested CARRY_LIMIT PlayerDrugData[playerid][Drugs];
        
format(stringsizeof(string), "DRUG PLANT: {FFFFFF}You harvested a drug plant and got %d grams of drugs."harvested);
        
SendClientMessage(playerid0x3498DBFFstring);
        
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_id0x3498DBFF"DRUG PLANT: {FFFFFF}Somebody harvested one of your drug plants!");
        
Plant_Destroy(id);
        
/* -- harvesting -- */
    
}else{
        
SendClientMessage(playerid0xE88732FF"SYNTAX: {FFFFFF}/plant [place/harvest]");
    } 
Reply
#2

Hello Druddd,
use a new variable which will store the drugid/plantid.

Like the following code below (which will not work until you edited)
PHP код:
/plant...
{
    
//stuff here
    
PlayerDrugData[playerid][DrugID] = PlantData[id][plantObj];

Reply
#3

I don't understand,can you make an example code?
Reply
#4

bump,help me please
Reply
#5

bumpp
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)