GetObjectModel help
#1

Hello am trying to make a cmd so player only able to use those objectids but seems like i doing something wrong because keep giving me this Invaild objectid use /attachableids hope u guys are able to help me out thanks in advance.

PHP код:
stock AttachAble(objectid)
{
    switch(
GetObjectModel(objectid))
    {
        case 
19601,19843,19796: return 1;
    }
    return 
0;
}
CMD:attachobject(playeridparams[])
{
    new 
objectmodelobjectidcar;
    if(
sscanf(params"ii"objectmodelcar))
    {
        
SendServerMessage(playerid"Use: /attachobject [object model] [SAMP Car ID]");
        return 
1;
    }
    if(!
AttachAble(objectid))
        return 
SendErrorMessage(playerid"Invaild objectid use /attachableids");
        
     if(
car MAX_VEHICLES)
     {
        new 
Float:pxFloat:pyFloat:pz;
          
GetPlayerPos(playeridpxpypz);
          
AttachingObjects[playerid] = CreateObject(objectmodelpxpypz0.00.00.0);
          
SendClientMessage(playerid0xfce80cFF"Object created. Editing...");
          
EditObject(playeridAttachingObjects[playerid]);
          
SetPVarInt(playerid"AttachingTo"car);
    }
    else
    {
        
SendErrorMessage(playerid"Invalid vehicle");
    }
    return 
1;

Reply
#2

Bump
Reply
#3

The player has to input the object model ID as a parameter so AttachAble function should not check the model as it's given already.
Change to:
pawn Код:
switch(objectid)
EDIT: This will need to modify the command as Antoniohl posted. I find easier to use it like this though:
pawn Код:
#define TYPE_OBJECT_ID 0
#define TYPE_OBJECT_MODEL_ID 1

AttachAble(object, type = 0)
{
    switch(!type ? GetObjectModel(object) : object)
    {
        case 19601,19843,19796: return 1;
    }
    return 0;
}
and then you can use your current code.
Reply
#4

Change your cmd to this
Код:
CMD:attachobject(playerid, params[])
{
    new objectmodel, car;
    if(sscanf(params, "ii", objectmodel, car))
    {
        SendServerMessage(playerid, "Use: /attachobject [object model] [SAMP Car ID]");
        return 1;
    }
    if(!AttachAble(objectmodel))
        return SendErrorMessage(playerid, "Invaild objectid use /attachableids");

     if(0 < car < MAX_VEHICLES)
     {
        new Float:px, Float:py, Float:pz;
          GetPlayerPos(playerid, px, py, pz);
          AttachingObjects[playerid] = CreateObject(objectmodel, px, py, pz, 0.0, 0.0, 0.0);
          SendClientMessage(playerid, 0xfce80cFF, "Object created. Editing...");
          EditObject(playerid, AttachingObjects[playerid]);
          SetPVarInt(playerid, "AttachingTo", car);
    }
    else
    {
        SendErrorMessage(playerid, "Invalid vehicle");
    }
    return 1;
}
Reply
#5

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
The player has to input the object model ID as a parameter so AttachAble function should not check the model as it's given already.
Change to:
pawn Код:
switch(objectid)
EDIT: This will need to modify the command as Antoniohl posted. I find easier to use it like this though:
pawn Код:
#define TYPE_OBJECT_ID 0
#define TYPE_OBJECT_MODEL_ID 1

AttachAble(object, type = 0)
{
    switch(!type ? GetObjectModel(object) : object)
    {
        case 19601,19843,19796: return 1;
    }
    return 0;
}
and then you can use your current code.
Still same problem.

Still getting this
PHP код:
SendErrorMessage(playerid"Invaild objectid use /attachableids"); 
Reply
#6

You are passing 'objectid' in the function but you are taking 'objectmodel' as input from user. So there is nothing being stored in 'objectid'.

Use the command that Antoniohl gave.
Reply
#7

Quote:
Originally Posted by BroZeus
Посмотреть сообщение
You are passing 'objectid' in the function but you are taking 'objectmodel' as input from user. So there is nothing being stored in 'objectid'.

Use the command that Antoniohl gave.
I did but same problem.
Reply
#8

PHP код:
AttachAble(objectmodel)
{
    switch(
objectmodel)
    {
        case 
19601,19843,19796: return 1;
    }
    return 
0;
}
CMD:attachobject(playeridparams[])
{
    new 
objectmodelcar;
    if(
sscanf(params"ii"objectmodelcar))
    {
        
SendServerMessage(playerid"Use: /attachobject [object model] [SAMP Car ID]");
        return 
1;
    }
    if(!
AttachAble(objectmodel))
        return 
SendErrorMessage(playerid"Invaild objectid use /attachableids");
     if(
car MAX_VEHICLES)
     {
          new 
Float:pxFloat:pyFloat:pz;
          
GetPlayerPos(playeridpxpypz);
          
AttachingObjects[playerid] = CreateObject(objectmodelpxpypz0.00.00.0);
          
SendClientMessage(playerid0xfce80cFF"Object created. Editing...");
          
EditObject(playeridAttachingObjects[playerid]);
          
SetPVarInt(playerid"AttachingTo"car);
    }
    else
    {
        
SendErrorMessage(playerid"Invalid vehicle");
    }
    return 
1;

You should use object model in every where not getting object model id, cause you're not attaching object on your car, you creating new one, so
Код:
GetObjectModel(objectid)
were unless

about the stock
https://sampforum.blast.hk/showthread.php?tid=570635
Reply
#9

Quote:
Originally Posted by jlalt
Посмотреть сообщение
PHP код:
AttachAble(objectmodel)
{
    switch(
objectmodel)
    {
        case 
19601,19843,19796: return 1;
    }
    return 
0;
}
CMD:attachobject(playeridparams[])
{
    new 
objectmodelcar;
    if(
sscanf(params"ii"objectmodelcar))
    {
        
SendServerMessage(playerid"Use: /attachobject [object model] [SAMP Car ID]");
        return 
1;
    }
    if(!
AttachAble(objectmodel))
        return 
SendErrorMessage(playerid"Invaild objectid use /attachableids");
     if(
car MAX_VEHICLES)
     {
          new 
Float:pxFloat:pyFloat:pz;
          
GetPlayerPos(playeridpxpypz);
          
AttachingObjects[playerid] = CreateObject(objectmodelpxpypz0.00.00.0);
          
SendClientMessage(playerid0xfce80cFF"Object created. Editing...");
          
EditObject(playeridAttachingObjects[playerid]);
          
SetPVarInt(playerid"AttachingTo"car);
    }
    else
    {
        
SendErrorMessage(playerid"Invalid vehicle");
    }
    return 
1;

You should use object model in every where not getting object model id, cause you're not attaching object on your car, you creating new one, so
Код:
GetObjectModel(objectid)
were unless

about the stock
https://sampforum.blast.hk/showthread.php?tid=570635
Thank you alot, rep
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)