Assigning an object an ID
#1

I've been toying around with something and I am trying to learn how to use objects.

This is a simple command, it allows you to get, drop and pickup a chair. It's got no purpose, I am simply using it to learn.

I know that to pick up the chair you will have to check the player is near the object and then destroy it, which requires an objectid. How can I assign an id to the object?

This is the command...

PHP код:
CMD:chair(playeridparams[])
{
    static
        
type[24];
        
    new
        
Float:x,
        
Float:y,
        
Float:z,
        
Float:a;
    
GetPlayerPos(playeridxyz);
    if (
sscanf(params"s[24]"type))
    {
         
SendSyntaxMessage(playerid"/chair [option]");
        
SendClientMessage(playeridCOLOR_YELLOW"[OPTIONS]:{FFFFFF} get, drop, pickup");
        return 
1;
    }
    if (!
strcmp(type"get"true))
    {
        if (
GetPVarInt(playerid"pCarryingChair") == 1)
            return 
SendErrorMessage(playerid"You are already carrying a chair.");
        for (new 
0!= MAX_VEHICLES++)
        if (
IsPlayerNearBoot(playeridi)
        {
            
SetPlayerAttachedObject(playerid117651, -1.1065041.5049880.0315840.00000089.5666350.000000);
            
SetPVarInt(playerid"pCarryingChair"1);
        }
    }
    if (!
strcmp(type"drop"true))
    {
        if (
GetPVarInt(playerid"pCarryingChair") == 0)
            return 
SendErrorMessage(playerid"You are not carrying a chair.");
        
GetPlayerFacingAngle(playerida);
        
CreateObject(1765xy z 1.00.00.0a50.0);
        
RemovePlayerAttachedObject(playerid1);
        
SetPVarInt(playerid"pCarryingChair"0);
    }
    if (!
strcmp(type"pickup"true))
    {
        if (
GetPVarInt(playerid"pCarryingChair) == 1)
            return SendErrorMessage(playerid, "
You are already carrying a chair.");
    }
    return 1;

Is it something like this?

PHP код:
new chair;
chair CreateObject(playerid1765xyz0.00.00.0); 
Reply


Messages In This Thread
Assigning an object an ID - by Luke_James - 06.09.2015, 23:22
Re: Assigning an object an ID - by Logofero - 07.09.2015, 00:50
Re: Assigning an object an ID - by Abagail - 07.09.2015, 02:27
Re: Assigning an object an ID - by Luke_James - 07.09.2015, 12:58
Re: Assigning an object an ID - by Logofero - 07.09.2015, 14:25
Re: Assigning an object an ID - by Luke_James - 07.09.2015, 15:02
Re: Assigning an object an ID - by Logofero - 07.09.2015, 15:11
Re: Assigning an object an ID - by Logofero - 07.09.2015, 15:24
Re: Assigning an object an ID - by Luke_James - 07.09.2015, 15:32
Re: Assigning an object an ID - by Logofero - 07.09.2015, 15:42

Forum Jump:


Users browsing this thread: 2 Guest(s)