SetPlayerAttachedObject doesn't seem to work for me - [03]Garsino - 28.11.2010
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 ?
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;
}
Re: SetPlayerAttachedObject doesn't seem to work for me -
boelie - 28.11.2010
Joining the question
Re: SetPlayerAttachedObject doesn't seem to work for me -
Kalcor - 28.11.2010
It worked fine on our end before release. If you're going to set the scale, probably test with 1.0 for X,Y,Z. 0.0 scale would be invisible.
Regarding the RemovePlayerAttachedObject crash, that could be a legit bug.
Re: SetPlayerAttachedObject doesn't seem to work for me - [03]Garsino - 28.11.2010
He also tried with default size (1) wich also is the default value for the size parameters in the command, meaning if he didn't type the whole command it would finish it off for him.
Re: SetPlayerAttachedObject doesn't seem to work for me -
Kalcor - 28.11.2010
What server is this, windows or linux?
Re: SetPlayerAttachedObject doesn't seem to work for me - [03]Garsino - 28.11.2010
Windows
(8char)
Re: SetPlayerAttachedObject doesn't seem to work for me -
Gforcez - 28.11.2010
Well, When i use my holdgun command (to attach a gun on the back), The client will crash :S.
Re: SetPlayerAttachedObject doesn't seem to work for me -
Kalcor - 28.11.2010
There seems to be a problem attaching objects if you are using GTA SA 1.0 EU exe. A fix will be posted shortly.
Re: SetPlayerAttachedObject doesn't seem to work for me - [03]Garsino - 28.11.2010
OK, good to hear
Re: SetPlayerAttachedObject doesn't seem to work for me -
Kalcor - 28.11.2010
https://sampforum.blast.hk/showthread.php?tid=194031
Should be fixed in 0.3c RC1-2. If you still have problems please report them here.
Re: SetPlayerAttachedObject doesn't seem to work for me -
Gforcez - 28.11.2010
Thanks, I will test it out now.
I will edit this post with the Result
EDIT: Fixed, It works for me now! Good Job
Re: SetPlayerAttachedObject doesn't seem to work for me - [03]Garsino - 28.11.2010
It works like it should now, I'll check for more crashes regarding SetPlayerAttachedObject itself though
EDIT: And you made a typo in the macro IsPlayerHoldingObject in the main post (you accedently added a ; at the end of the macro).
Re: SetPlayerAttachedObject doesn't seem to work for me -
The_Moddler - 28.11.2010
Still.. doesn't work for me..
I discovered something(I hope..)
When you enter a car in my GM, it says the engine status and if is owned or not, taking out the -1 on MAX_PLAYER_ATTACHED_OBJECTS just spammed those messages that are only suposed to send it one time, I rechecked the script, and took out SetPlayerAttachedObject, and I did not spam.. so maybe a clue for you, Kye.
Edit:
Ah no.. fuck me.. I was downloading server instead of client.. now works.. sorry.