28.01.2011, 18:15
Well if you declare the variable a in the command, it's scope will be limited to that command. You would need something like a PVar.
pawn Код:
if(!strcmp(cmd, "/plant", true))
{
if(GetPVarInt(playerid,"WeedID") != -1)
{
//They already planted one
return 1;
}
new
Float:X,
Float:Y,
Float:Z,
Float:A;
GetPlayerFacingAngle(playerid,A);
GetPlayerPos(playerid, X, Y, Z);
X += (4 * floatsin(-A, degrees));
Y += (4 * floatcos(-A, degrees));
SetPVarInt(playerid,"WeedID",CreateObject(688, X, Y, Z, 0.0, 0.0, 96.0));
return 1;
}
if(!strcmp(cmd, "/pickweed", true))
{
if(GetPVarInt(playerid,"WeedID") == -1)
{
//They haven't planted one
return 1;
}
DestroyObject(GetPVarInt(playerid,"WeedID"));
SetPVarInt(playerid,"WeedID",-1);
//Rest of your pick weed code
return 1;
}