28.11.2010, 15:10
My friend tested this code for me, and surprisingly it didn't set the player to "hold" the object...
He said he tried with several object IDs (1225 - red barrel, 1337 - trashcan, and a few others) and all bodyparts and still the same result. He also tried adjusting the rotation, offset and size...
Is there anything wrong with my code or is this some sort of bug ?
He said he tried with several object IDs (1225 - red barrel, 1337 - trashcan, and a few others) and all bodyparts and still the same result. He also tried adjusting the rotation, offset and size...
Is there anything wrong with my code or is this some sort of bug ?
pawn Код:
dcmd_sethobj(playerid, params[])
{
if(IsPlayerAdmin(playerid))
{
new id, modelid, slot, Float:rX[3], Float:rY[3], Float:rZ[3], string[128], bodypart[35];
if(sscanf(params, "udds[35]F(0)F(0)F(0)F(0)F(0)F(0)F(1)F(1)F(1)", id, modelid, slot, bodypart, rX[0], rY[0], rZ[0], rX[1], rY[1], rZ[1], rX[2], rY[2], rZ[2])) return SendClientMessage(playerid, COLOUR_SYSTEM, "Usage: /sethobj (nick/id) (modelid) (slot: 0-4) (bodypart: name/id) (rotX) (rotY) (rotZ) (rotX) (rotY) (rotZ) (sizeX) (sizeY) (sizeZ)");
if(strlen(bodypart) < 1 || strlen(bodypart) > 35 || GetBodypartIDFromName(bodypart) == -1) return SendClientMessage(playerid, COLOUR_SYSTEM, "Invalid Bodypart Name/ID.");
if(slot < 0 || slot > 4) return SendClientMessage(playerid, COLOUR_SYSTEM, "Invalid slot ID. Valid slot IDs are between 0-4.");
if(!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOUR_SYSTEM, "This player is not connected!");
else
{
if(IsPlayerAttachedObjectSlotUsed(id, slot))
{
RemovePlayerAttachedObject(id, slot); // It also crashed on this line when the player weren't "holding" a object in this slot, idk why... (before I added the check above)
}
SetPlayerAttachedObject(id, slot, modelid, GetBodypartIDFromName(bodypart), rX[0], rY[0], rZ[0], rX[1], rY[1], rZ[1], rX[2], rY[2], rZ[2]);
format(string, sizeof(string), "Modelid %d has been attached to %s's (%d) Bodypart [%s].", modelid, pNick(id), id, GetBodypartName(bodypart));
SendClientMessage(playerid, COLOUR_INFO, string);
}
return 1;
}
else return 0;
}