29.01.2011, 11:06
Hello,
I need help with the following code:
So I made the new Float:WeedX etc. above the script.
So the command /plantweed gets the playerposition in
the Weed-X, Y, Z., And i wanted to use it in the /pickweed
command but it doesn't know where the position is, so the
position only get saved when the player types /plantweed..
So, what should i do, what's the simplest way to make the
WeedX etc.. a local variable?
I need help with the following code:
pawn Код:
if(strcmp(cmd, "/plantweed", true) == 0)
{
if(PlayerInfo[playerid][pWeedSeeds] > 9)
{
if(PlantedWeed[playerid] == -1)
{
GetPlayerPos(playerid, WeedX, WeedY, WeedZ);
PlayerInfo[playerid][pWeedSeeds] -= 10;
PlantedWeed[playerid] = CreateObject(688, WeedX+1, WeedY+1, WeedZ, 0.0, 0.0, 96.0);
HasPlanted[playerid] = 1;
SendClientMessage(playerid, COLOR_GREEN, " You've planted a weed plant with 10 seeds.");
}
else
{
SendClientMessage(playerid, COLOR_GREY, " There is already a weed plant that belongs to you.");
}
}
else
{
SendClientMessage(playerid, COLOR_GREY, " You don't have enough seeds, you need 10 seeds.");
}
return 1;
}
if(strcmp(cmd, "/pickweed", true) == 0)
{
if(HasPlanted[playerid] == 1)
{
if(IsPlayerInRangeOfPoint(playerid, 3, WeedX, WeedY, WeedZ))
{
DestroyObject(PlantedWeed[playerid]);
PlantedWeed[playerid] = -1;
PlayerInfo[playerid][pWeed] += 50;
SendClientMessage(playerid, COLOR_RED, " You've picked your plant and got 50 grammes of weed.");
}
else
{
SendClientMessage(playerid, COLOR_YELLOW, " You're not near your weed plant.");
}
}
else
{
SendClientMessage(playerid, COLOR_GREY, " You need to plant a weed plant before picking it.");
}
return 1;
}
So the command /plantweed gets the playerposition in
the Weed-X, Y, Z., And i wanted to use it in the /pickweed
command but it doesn't know where the position is, so the
position only get saved when the player types /plantweed..
So, what should i do, what's the simplest way to make the
WeedX etc.. a local variable?