A problem with my getobjectpos
#1

Hey! Since i cannot seem to fix this myself i gotta ask you peeps!
Well the problem is like this, people can plant some stuff, it then evolves into a new object and people are able to take it.. But the problem is it only works for the last thing that was planted, could anybody help me out? Or give me some info about what i have to do or anything i forgot ? I really need this fixed.

This is the plant thing.
pawn Code:
new Float:wX, Float:wY, Float:wZ;
format(string, sizeof(string), "You planted a weed plant, now wait for it to grow");
SendClientMessage(playerid, COLOR_WHITE, string);
PlayerInfo[playerid][pDrugs] -= 4;
WeedPlanted[playerid] += 1;
IsReadyToPickup[playerid] = 0;
GetPlayerPos(playerid, wX, wY, wZ);
PlayerInfo[playerid][pWeedPlant] = CreateObject(3409, wX, wY, wZ-1, 0.0, 0.0, 0.0);
weedplant[playerid] += 1;
SetTimerEx("PlantedWeed",192000,false, "i", playerid);

ApplyAnimation(playerid, "BOMBER","BOM_Plant_Loop",4.0,0,0,0,0,1000);
The pickup command
pawn Code:
new Float:wX, Float:wY, Float:wZ;
GetObjectPos(PlayerInfo[i][pWeedPlante], wX, wY, wZ);
if(PlayerToPoint(6, playerid, wX, wY, wZ))
{
  {
    IsReadyToPickup[playerid] = 0;
    ApplyAnimation(playerid, "BOMBER","BOM_Plant_Loop",4.0,0,0,0,0,1000);
    WeedPlanted[playerid] = 0;
    weedplant[playerid] = 0;
    new rand = random(3)+4;
    new str[256];               //string
    format(str,sizeof(str),"You got %i grams weed from the plant.",rand);
                         //send the string
    SendClientMessage(playerid,COLOR_WHITE,str);
    PlayerInfo[playerid][pWeed] += rand;
    PlayerInfo[playerid][pWeedPlant] = 0;
    DestroyObject(PlayerInfo[i][pWeedPlante]);
    SetTimer("WeedDestroy",10,0);
    return 1;
  }
}


else
{
  SendClientMessage(playerid, COLOR_WHITE, "You are not near any plants, or its not ready yet.");
  return 1;
}
And the public.
pawn Code:
public PlantedWeed(playerid)
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
      new Float:wX, Float:wY, Float:wZ;
      GetObjectPos(PlayerInfo[playerid][pWeedPlant], wX, wY, wZ);
        PlayerInfo[playerid][pWeedPlante] = CreateObject(3409, wX, wY, wZ, 0.0, 0.0, 0.0);
      DestroyObject(PlayerInfo[playerid][pWeedPlant]);
        weedplant[playerid] = 0;
        SetTimer("WeedDestroy",425000,0);
        return 1;
    }
    return 1;
}
So now i posted what is needed, could anybody help me out ? I would really appreciate it
Reply
#2

pawn Code:
//PlayerInfo[playerid][pWeedPlant] = CreateObject(3409, wX, wY, wZ-1, 0.0, 0.0, wA+1);
//PlayerInfo[playerid][pWeedPlant] = 1;
See what you did there? If that's how you had your code, then yes, it shouldn't be working. You set pWeedPlant to whatever the created object's id is, but then you set it to 1.
Reply
#3

Quote:
Originally Posted by Backwardsman97
pawn Code:
//PlayerInfo[playerid][pWeedPlant] = CreateObject(3409, wX, wY, wZ-1, 0.0, 0.0, wA+1);
//PlayerInfo[playerid][pWeedPlant] = 1;
See what you did there? If that's how you had your code, then yes, it shouldn't be working. You set pWeedPlant to whatever the created object's id is, but then you set it to 1.
I never used it, sorry i forgot to delete it here
Got any other suggestion?
Reply
#4

I don't exactly understand what the problem is.
Reply
#5

Sorry for my bad explaining, Alright lets say Paul and Jon is online,
Paul does /plant
[A tree comes up] - Everything is fine, the timer starts and all.
Jon does /plant
[A tree comes up] - Everything is fine.

But then they /pickup, Paul's plant doesn't work where Jon's does because he created the last plant.
It overwrites the wX,wY ,wZ somewhere.. Might be the public, but i don't have that much experience in pawn to fix that bug.
Reply
#6

My problem is this little guy in your /pickup command.

pawn Code:
GetObjectPos(PlayerInfo[i][pWeedPlante], wX, wY, wZ);
Well you mis-spelled Plant which should have given you an error. Also, you put PlayerInfo[i] when later you use playerid. So it should be like this.

pawn Code:
GetObjectPos(PlayerInfo[playerid][pWeedPlant], wX, wY, wZ);
Also, under your pickup command you have this.

pawn Code:
if(PlayerToPoint(6, playerid, wX, wY, wZ))
{
  {
There is no need for two opening brackets. I think the compiler will ignore it, but it is unnecessary.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)