command(plantseed, playerid, params[])
{
if(Player[playerid][Seeds] == 0)
return SendClientMessage(playerid, RED, "> You don't have any seeds!");
{
SendClientMessage(playerid, WHITE, "You've planted one seed!");
SetTimerEx("WeedTimer", 20000, 0, "i", playerid);
Player[playerid][Seeds] -= 1;
new Float:Weedx, Float:Weedy, Float:Weedz, Float:Weeda;
GetPlayerFacingAngle(playerid, Weeda);
GetPlayerPos(playerid, Weedx, Weedy, Weedz);
Player[playerid][Seeds] = CreateObject(3409, Weedx, Weedy, Weedz - 1.3, 0.0, 0.0, Weeda + 90);
SavePlayerData(playerid);
}
return 1;
}
command(takeweed, playerid, params[])
{
new Float:Weedx, Float:Weedy, Float:Weedz, Float:Weeda;
GetPlayerFacingAngle(playerid, Weeda);
GetPlayerPos(playerid, Weedx, Weedy, Weedz);
if(Player[playerid][TakeWeed] == 0)
return SendClientMessage(playerid, RED, "> You don't have any weed to take!");
{
if(IsPlayerInRangeOfPoint(playerid, 2, Weedx, Weedy, Weedz))
{
if(GetPlayerWeapon(playerid) == 4)
{
SetTimerEx("Takingweed", 20000, 0, "i", playerid);
TogglePlayerControllable(playerid, false);
ApplyAnimation(playerid, "BOMBER","BOM_Plant_Loop",4.0,1,0,1,1,0);
}
else
{
SendClientMessage(playerid, RED, "> You don't have an knife on you!");
}
}
else
{
SendClientMessage(playerid, RED, "> You are not near your weed!");
}
}
return 1;
}
new Float:Weedx[MAX_PLAYERS], Float:Weedy[MAX_PLAYERS], Float:Weedz[MAX_PLAYERS];
#define MAX_PLANTS 5 new Float:Weedx[MAX_PLAYERS][MAX_PLANTS], Float:Weedy[MAX_PLAYERS][MAX_PLANTS], Float:Weedz[MAX_PLAYERS][MAX_PLANTS];
Go on these coords = 0,0,0 and it should work
![]() For one plant per player do something like this, but GLOBAL Код HTML:
new Float:Weedx[MAX_PLAYERS], Float:Weedy[MAX_PLAYERS], Float:Weedz[MAX_PLAYERS]; Код HTML:
#define MAX_PLANTS 5 new Float:Weedx[MAX_PLAYERS][MAX_PLANTS], Float:Weedy[MAX_PLAYERS][MAX_PLANTS], Float:Weedz[MAX_PLAYERS][MAX_PLANTS]; |
#define MAX_PLANTS 300
#define MAX_PLANTS Your amount
for(new i = 0; i < MAX_PLANTS; ++i)
{
if(IsValidDynamicObject(Plants[i][pObjectSpawned]) && IsPlayerInRangeOfPoint(playerid, 2.5, Plants[i][pPos][0], Plants[i][pPos][1], Plants[i][pPos][2]))
{
if(GetPlayerVirtualWorld(playerid) == Plants[i][pVirtual] && GetPlayerInterior(playerid) == Plants[i][pInterior])
{
Wrong. It won't work if he goes to 0,0,0 coords. Give me a few minutes while I look at your code.
Edit: Are you sure your positions are fine? The object might be underground. |
First define the MAX plants
PHP код:
PHP код:
PHP код:
|
The object spawns at your location, Above the ground, So yea its on teh right posistion
|
Then I assume the issue is with taking the weed? Let me take a look again.
The issue is your variables are local and not global, make them global by deleting all of the weedx,weedy etc. and re-write them on top of your script beneath other new variables. Aside of that, you are basically saving a player's position and loading stuff back from the player's position instead of weed's position. If you didn't quite grasp what I mean, I can show you an example. |
new Float:Weedx[MAX_PLAYERS], Float:Weedy[MAX_PLAYERS], Float:Weedz[MAX_PLAYERS], Float: Weeda[MAX_PLAYERS];
command(plantseed, playerid, params[])
{
if(Player[playerid][Seeds] == 0)
return SendClientMessage(playerid, RED, "> You don't have any seeds!");
{
SendClientMessage(playerid, WHITE, "You've planted one seed!");
SetTimerEx("WeedTimer", 20000, 0, "i", playerid);
Player[playerid][Seeds] -= 1;
GetPlayerFacingAngle(playerid, Weeda(playerid));
GetPlayerPos(playerid, Weedx(playerid), Weedy(playerid), Weedz(playerid));
Player[playerid][Seeds] = CreateObject(3409, Weedx(playerid), Weedy(playerid), Weedz(playerid) - 1.3, 0.0, 0.0, Weeda(playerid) + 90);
SavePlayerData(playerid);
}
return 1;
}
command(takeweed, playerid, params[])
{
GetObjectPos(Player[playerid][Seeds],Weedx(playerid),Weedy(playerid),Weedz(playerid));
if(Player[playerid][TakeWeed] == 0)
return SendClientMessage(playerid, RED, "> You don't have any weed to take!");
{
if(IsPlayerInRangeOfPoint(playerid, 2, Weedx(playerid), Weedy(playerid), Weedz(playerid)))
{
if(GetPlayerWeapon(playerid) == 4)
{
SetTimerEx("Takingweed", 20000, 0, "i", playerid);
TogglePlayerControllable(playerid, false);
ApplyAnimation(playerid, "BOMBER","BOM_Plant_Loop",4.0,1,0,1,1,0);
}
else
{
SendClientMessage(playerid, RED, "> You don't have an knife on you!");
}
}
else
{
SendClientMessage(playerid, RED, "> You are not near your weed!");
}
}
return 1;
}
GetPlayerFacingAngle(playerid, Weeda(playerid)); |
C:\Users\Davey\Desktop\DL-RP.pwn(8706) : error 012: invalid function call, not a valid address C:\Users\Davey\Desktop\DL-RP.pwn(8706) : warning 215: expression has no effect C:\Users\Davey\Desktop\DL-RP.pwn(8706) : error 001: expected token: ";", but found ")" C:\Users\Davey\Desktop\DL-RP.pwn(8706) : error 029: invalid expression, assumed zero C:\Users\Davey\Desktop\DL-RP.pwn(8706) : fatal error 107: too many error messages on one line Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase 4 Errors. |
new Float:Weedx[MAX_PLAYERS], Float:Weedy[MAX_PLAYERS], Float:Weedz[MAX_PLAYERS], Float: Weeda[MAX_PLAYERS];
command(plantseed, playerid, params[])
{
if(Player[playerid][Seeds] == 0)
return SendClientMessage(playerid, RED, "> You don't have any seeds!");
{
SendClientMessage(playerid, WHITE, "You've planted one seed!");
SetTimerEx("WeedTimer", 20000, 0, "i", playerid);
Player[playerid][Seeds] -= 1;
GetPlayerFacingAngle(playerid, Weeda[playerid]);
GetPlayerPos(playerid, Weedx[playerid], Weedy[playerid], Weedz[playerid]);
Player[playerid][Seeds] = CreateObject(3409, Weedx[playerid], Weedy[playerid], Weedz[playerid] - 1.3, 0.0, 0.0, Weeda[playerid] + 90);
SavePlayerData(playerid);
}
return 1;
}
command(takeweed, playerid, params[])
{
GetObjectPos(Player[playerid][Seeds],Weedx[playerid],Weedy[playerid],Weedz[playerid]);
if(Player[playerid][TakeWeed] == 0)
return SendClientMessage(playerid, RED, "> You don't have any weed to take!");
{
if(IsPlayerInRangeOfPoint(playerid, 2, Weedx[playerid], Weedy[playerid], Weedz[playerid]))
{
if(GetPlayerWeapon(playerid) == 4)
{
SetTimerEx("Takingweed", 20000, 0, "i", playerid);
TogglePlayerControllable(playerid, false);
ApplyAnimation(playerid, "BOMBER","BOM_Plant_Loop",4.0,1,0,1,1,0);
}
else
{
SendClientMessage(playerid, RED, "> You don't have an knife on you!");
}
}
else
{
SendClientMessage(playerid, RED, "> You are not near your weed!");
}
}
return 1;
}