stock AttachAble(objectid)
{
switch(GetObjectModel(objectid))
{
case 19601,19843,19796: return 1;
}
return 0;
}
CMD:attachobject(playerid, params[])
{
new objectmodel, objectid, car;
if(sscanf(params, "ii", objectmodel, car))
{
SendServerMessage(playerid, "Use: /attachobject [object model] [SAMP Car ID]");
return 1;
}
if(!AttachAble(objectid))
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;
}
switch(objectid)
#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;
}
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;
}
|
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 Код:
pawn Код:
|
SendErrorMessage(playerid, "Invaild objectid use /attachableids");
|
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. |
AttachAble(objectmodel)
{
switch(objectmodel)
{
case 19601,19843,19796: return 1;
}
return 0;
}
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;
}
GetObjectModel(objectid)
|
PHP код:
Код:
GetObjectModel(objectid) about the stock https://sampforum.blast.hk/showthread.php?tid=570635 |