Picking up crates - array - playertopoint
#1

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:

PHP Code:
YCMD:pickupcrate(playeridparams[], help)
{
    
#pragma unused help
    
new Float:xFloat:yFloat:z;
        for(new 
ii<=sizeof(crate); i++)
        {
        
GetObjectPos(crate[i], xyz); //gets position of every crate 
    
if(PlayerToPoint(1playeridxyz))//any crate???
    
{
            
//picking up that crate
            
ApplyAnimation(playerid"CARRY""liftup"4.001111);
        
SetTimerEx("PokupioKutiju"1000false"i"playerid);
        
SetPlayerSpecialAction(playeridSPECIAL_ACTION_CARRY);
    
    }else 
SendClientMessage(playeridCOLOR_WHITE"You are not close enough to any crate".);
    }
    return 
1;

timer "PokupioKutiju":

PHP Code:
forward PokupioKutiju(playerid);
public 
PokupioKutiju(playerid)
{
    
SetPlayerAttachedObject(playerid0301460.0959990.251999, -0.146999, -116.199989, -20.90000579.199981);
    
//DestroyObject(crate[i]); // how to work with this ???
    
ApplyAnimation(playerid"CARRY""crry_prtial"4.011111);
    
SetPlayerSpecialAction(playeridSPECIAL_ACTION_CARRY);
    
    return 
1;

Command /leavecrate:

PHP Code:
YCMD:leavecrate(playeridparams[], help)
{
    
#pragma unused help
    
    
    
new Float:pxFloat:pyFloat:pz;
    
GetPlayerPos(playeridpxpypz);
    for(new 
i=0i<MAX_PLAYER_ATTACHED_OBJECTSi++){if(IsPlayerAttachedObjectSlotUsed(playeridi)) RemovePlayerAttachedObject(playeridi);}
    
ApplyAnimation(playerid"CARRY""putdwn"4.001011);
    
SetTimerEx("SpustioKutiju"1000false"i"playerid); //this timer only clear animations
    
crate[i] = CreateObject(3014pxpypz-0.800.000000.000000); //???
    
SetObjectPos(crate01pxpypz-0.80);
    return 
1;

Reply


Messages In This Thread
Picking up crates - array - playertopoint - by Saddin - 11.04.2017, 13:27
Re: Picking up crates - array - playertopoint - by DarkSkull - 11.04.2017, 13:40
Re: Picking up crates - array - playertopoint - by AndreiWow - 11.04.2017, 13:41
Re: Picking up crates - array - playertopoint - by Saddin - 11.04.2017, 13:42
Re: Picking up crates - array - playertopoint - by DarkSkull - 11.04.2017, 13:44

Forum Jump:


Users browsing this thread: 1 Guest(s)