11.04.2017, 13:27
I have a problem and a question.
I am trying to make command that picks first close (available) create to do something with it... with a command.
For example, I type /pickupcrate it should check for playertopoint if it is close enough to pick it up and than do something with it. I have already done that. Problem is when 5 crates in an array (crates[5]) are on one big pile and when I type /pickupcrate i pick all of them.
Also there is a problem. When I use another command for example /leavecrate I can't make it work because I cannot get information from last command (/pickupcrate) which crate I picked up. For example if I picked up crate[3] how do I know is that corred position of crate array.
Commands:
timer "PokupioKutiju":
Command /leavecrate:
I am trying to make command that picks first close (available) create to do something with it... with a command.
For example, I type /pickupcrate it should check for playertopoint if it is close enough to pick it up and than do something with it. I have already done that. Problem is when 5 crates in an array (crates[5]) are on one big pile and when I type /pickupcrate i pick all of them.
Also there is a problem. When I use another command for example /leavecrate I can't make it work because I cannot get information from last command (/pickupcrate) which crate I picked up. For example if I picked up crate[3] how do I know is that corred position of crate array.
Commands:
PHP Code:
YCMD:pickupcrate(playerid, params[], help)
{
#pragma unused help
new Float:x, Float:y, Float:z;
for(new i; i<=sizeof(crate); i++)
{
GetObjectPos(crate[i], x, y, z); //gets position of every crate
if(PlayerToPoint(1, playerid, x, y, z))//any crate???
{
//picking up that crate
ApplyAnimation(playerid, "CARRY", "liftup", 4.0, 0, 1, 1, 1, 1);
SetTimerEx("PokupioKutiju", 1000, false, "i", playerid);
SetPlayerSpecialAction(playerid, SPECIAL_ACTION_CARRY);
}else SendClientMessage(playerid, COLOR_WHITE, "You are not close enough to any crate".);
}
return 1;
}
PHP Code:
forward PokupioKutiju(playerid);
public PokupioKutiju(playerid)
{
SetPlayerAttachedObject(playerid, 0, 3014, 6, 0.095999, 0.251999, -0.146999, -116.199989, -20.900005, 79.199981);
//DestroyObject(crate[i]); // how to work with this ???
ApplyAnimation(playerid, "CARRY", "crry_prtial", 4.0, 1, 1, 1, 1, 1);
SetPlayerSpecialAction(playerid, SPECIAL_ACTION_CARRY);
return 1;
}
PHP Code:
YCMD:leavecrate(playerid, params[], help)
{
#pragma unused help
new Float:px, Float:py, Float:pz;
GetPlayerPos(playerid, px, py, pz);
for(new i=0; i<MAX_PLAYER_ATTACHED_OBJECTS; i++){if(IsPlayerAttachedObjectSlotUsed(playerid, i)) RemovePlayerAttachedObject(playerid, i);}
ApplyAnimation(playerid, "CARRY", "putdwn", 4.0, 0, 1, 0, 1, 1);
SetTimerEx("SpustioKutiju", 1000, false, "i", playerid); //this timer only clear animations
crate[i] = CreateObject(3014, px, py, pz-0.80, 0.00000, 0.00000, 0); //???
SetObjectPos(crate01, px, py, pz-0.80);
return 1;
}