Object IDs
#1

How to give out to my objects i've created with this command ids.

PHP код:
new ObjectIDModelIDFloat:oXFloat:oYFloat:oZ;
new 
ObjectSpawned[MAX_PLAYERS];
CMD:object(playerid,params[])
{
  if(!
IsPlayerAdmin(playerid)) return SendClientMessage(playerid,red,"Command not found! Type /cmds");
  if(
sscanf(params"i",ModelID)) return SendClientMessage(playerid,red,"Create object: /object <model>");
  {
    
GetPlayerPos(playerid,oX,oY,oZ);
    
ObjectID CreateObject(ModelID,oX,oY,oZ,0,0,0);
    
EditObject(playerid,ObjectID);
    
ObjectSpawned[playerid] = 1;
  }
  return 
1;

Example: "Object id: 1 ModelID 19128"
"Object id: 2 ModelID 19125" etc..

Thanks
Reply
#2

This should help you out a little. (Just woke up, so it was the last thing i wanted to do)

pawn Код:
enum oInfo
{
    ObjectID,
    Float:POS[6],
    ModelID,
    Object,
    BeingUsed,
};
new ObjectInformation[MAX_OBJECTS][oInfo];



public OnPlayerEditDynamicObject(playerid, objectid, response, x, y, z, rx, ry, rz)
{

}

COMMAND:object(playerid, params[], modelid)
{
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, red, "This command was not found, please use /cmds for all the commands on the server");
    if(sscanf(params, "d", modelid)) return SendClientMessage(playerid, red, "[USAGE]: /model [modelid]");

    new Float: PPOS[4],
        FreeSlot = GetFreeObjectSlot();

    GetPlayerPos(playerid, PPOS[0], PPOS[1], PPOS[2])
    //GetPlayerFacingAngle(playerid, POS[3]) Just if you wish to rotate the object based on the players rotation.
    ObjectInformation[FreeSlot][Object] = CreateDynamicObject(modelid, POS[0], PPOS[1], PPOS[2], 0,0,0);
    ObjectInformation[FreeSlot][ObjectID] = FreeSlot + 1;
    ObjectInformation[FreeSlot][POS][0] = PPOS[0];
    ObjectInformation[FreeSlot][POS][1] = PPOS[1];
    ObjectInformation[FreeSlot][POS][2] = PPOS[2];
    ObjectInformation[FreeSlot][POS][3] = 0;
    ObjectInformation[FreeSlot][POS][4] = 0;
    ObjectInformation[FreeSlot][POS][5] = 0;
}

stock GetFreeObjectSlot()
{
    for(new i = 0; i < MAX_OBJECTS; i++)
    {
        if(ObjectInformation[i][BeingUsed])
            continue;
        else
            return i;
    }
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)