Making an array
#1

Hey,

I am using a edited version of a filterscript released on samp forums of Weed growing, problem is it only includes making of 1 plant only, while i want to make 5 plants.

This is plant cmd:

PHP код:
COMMAND:plantweed(playeridparams[])
{
    if(
playerData[playerid][playerLoggedIn])
    {
         if(
GetPlayerState(playerid) != PLAYER_STATE_ONFOOT) return SendClientMessage(playeridCOLOR_GREY"SERVER: You must be onfoot to perform this command.");
         if(
WeedInfo[playerid][wAbleToPlant] < && playerData[playerid][wSeeds] > 0)
            {
                 for(new 
weed 0weed sizeof(WeedInfo); weed++)
                {
                                new 
Float:X,Float:Y,Float:Z;
                                
ApplyAnimation(playerid"BOMBER","BOM_Plant_In",4.0,0,0,0,0,0);
                                
ApplyAnimation(playerid"BOMBER","BOM_Plant_In",4.0,0,0,0,0,0); // Applying it twice for ensurity
                                
GetPlayerPos(playeridXYZ);
                                
WeedInfo[weed][wPlantObject] = CreateDynamicObject(3409XYZ-1.00000);
                                
WeedInfo[weed][wX] = X;
                                
WeedInfo[weed][wY] = Y;
                                
WeedInfo[weed][wZ] = Z;
                               
playerData[playerid][wSeeds] = playerData[playerid][wSeeds] - 1;
                                
WeedInfo[weed][wLabel] = Create3DTextLabel("PLANT STATUS: Not ready for picking.",COLOR_SILVER,WeedInfo[weed][wX],WeedInfo[weed][wY],WeedInfo[weed][wZ],10.0,0);
                                
WeedInfo[weed][wLabels]++;
                                
WeedInfo[playerid][wAbleToPlant] = WeedInfo[playerid][wAbleToPlant] +1;
                                
SetTimer("PlantWeedTimer",1000*5,0); // 60 seconds times 5 = 5 minutes.
                                
SendClientMessage(playerid,COLOR_GREEN,"INFO: You have planted your seeds, it will now grow and be ready to /pickweed pick in 5 minutes.");
                                return 
1;
                                }
                        }
                        else 
SendClientMessage(playerid,COLOR_GREY,"INFO: Unable to plant seeds, you already have a tleast 5 active plants to maintain. or have no seeds");
    }
    else
    {
        return 
SendClientMessage(playeridCOLOR_WHITE"{FF0404}[ERROR] {FFFF00}You must be logged in to use commands.");
    }
        return 
1;

This is the enum:
PHP код:
enum wInfo
{
    
wAbleToPlant,
    
bool:wAbleToPick,
    
wPlantObject,
        
Float:wX,
        
Float:wY,
        
Float:wZ,
        
Text3D:wLabel,
        
wLabels
        
}; 
This pickweed

PHP код:
COMMAND:pickweed(playeridparams[])
{
    if(
playerData[playerid][playerLoggedIn])
    {
            if(
IsPlayerInRangeOfPoint(playerid,5.0,WeedInfo[playerid][wX],WeedInfo[playerid][wY],WeedInfo[playerid][wZ]))
                {
                            for(new 
weed 0weed sizeof(WeedInfo); weed++)
                            {
                            if(
WeedInfo[playerid][wAbleToPick] == falseSendClientMessage(playerid,COLOR_GREY,"INFO: You do not have an active plant growing to pick.");
                                    
ApplyAnimation(playerid"BOMBER","BOM_Plant_In",4.0,0,0,0,0,0);
                                        
WeedInfo[weed][wAbleToPick] = false;
                                        
DestroyDynamicObject(WeedInfo[weed][wPlantObject]);
                                        
playerData[playerid][playerWeed] = playerData[playerid][playerWeed] + 5;
                                        
SendClientMessage(playeridCOLOR_GREEN,"INFO: You have picked your marijuana growth, and gained 5 grams +2 score in total.");
                                        
Delete3DTextLabel(WeedInfo[weed][wLabel]);
                                        
WeedInfo[playerid][wAbleToPlant] = WeedInfo[playerid][wAbleToPlant] -1;
                                        
WeedInfo[weed][wLabels]--;
                                        return 
1;
                                }
                        }
                        else 
SendClientMessage(playerid,COLOR_GREY,"INFO: You are not near any plants.");
     }
    else
    {
        return 
SendClientMessage(playeridCOLOR_WHITE"{FF0404}[ERROR] {FFFF00}You must be logged in to use commands.");
    }
        
    return 
1;    

and finally this is the weedtimer

PHP код:
public PlantWeedTimer(playerid)
{
        
Update3DTextLabelText(WeedInfo[playerid][wLabel],COLOR_SILVER,"PLANT STATUS: Ready to be picked. Use /pickweed pick");
        
WeedInfo[playerid][wAbleToPick] = true;


i want to make it like, player can plant 5 plants, not only 1.

Any help please?
Reply
#2

Bump
Reply
#3

I remind you that this section isn't for requests, have you tried anything to achieve what you want?
Reply
#4

You probably didn't read the thread lmao, I am requesting a help regarding scripting.... 'Making an array' maybe read full thread?

I could make it in a way that would be tooooooo much unoptimized... And tons of code.
Reply
#5

Quote:
Originally Posted by iLearner;
i want to make it like, player can plant 5 plants, not only 1.

Any help please?
That looks like a request, and the first part of your message makes it look like you haven't tried anything at all.

Quote:
Originally Posted by iLearner
Посмотреть сообщение
You probably didn't read the thread lmao, I am requesting a help regarding scripting.... 'Making an array' maybe read full thread?
You should define "help regarding scripting", because I don't see it being requests, rather "how to fix something that's not working as intended". Explanations can pass by, but anything other than those, are technically requests (e.g. i want to make it like, player can plant 5 plants, not only 1). Requests don't go in this section.

--------------------------------------------------------------------------

But looking at your code, look here:
pawn Код:
WeedInfo[playerid][wAbleToPlant]
pawn Код:
WeedInfo[weed][wX] = X;
Look at the first dimension, the first array is misleading and wrong.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)