SetPlayerHoldingObject -> 0.3c feature.
#1

Hey guys. Im still using the SetPlayerHoldingObject which had been used in 0.3b on my gamemode, and i want to upgrade it to the 0.3c feature with the 5 slots. (currently i have a define, that when SetPlayerHoldingObject is used, it is attached to slot 1.

The usage currently is:
/attach <modelid> <bone> <x> <y> <z> <rotx> <roty> <rotz> <comment>
I want it to work like that:
/attach <slot> <modelid> <bone> <x> <y> <z> <rotx> <roty> <rotz> <comment>

And the /unattach command currently uses StopPlayerHoldingObject
I want it to work like that:
/unattach -> unattaches ANYHING, from every slot (if i habe 5 objects atatched and i do /unattach, it should
remove them all, not like on other servers when you have to /unattach slot 1, /unattach slot 2, /unattach slot 3 blahblah...

My defines (should not be changed if possible, cuz i have other commands using the SetPlayerHolding ojects which should stay, the 7attach is for admins only for now.)

Код:
#define SetPlayerHoldingObject(%1,%2,%3,%4,%5,%6,%7,%8,%9) SetPlayerAttachedObject(%1,MAX_PLAYER_ATTACHED_OBJECTS-1,%2,%3,%4,%5,%6,%7,%8,%9)
#define StopPlayerHoldingObject(%1) RemovePlayerAttachedObject(%1,MAX_PLAYER_ATTACHED_OBJECTS-1)
#define IsPlayerHoldingObject(%1) IsPlayerAttachedObjectSlotUsed(%1,MAX_PLAYER_ATTACHED_OBJECTS-1)
Here are the pawno codes, please can anyone rescript it, i rly have no clue what to change, cuz i never dealt with dcmd's, on only had the normal strcmnds, and this here is a big to hard & i dont wanna test it 20 ages long.
Код:
dcmd_attach(playerid, params[])
{
	if(PlayerInfo[playerid][pTester] != 3)
	    return SendClientMessage(playerid, COLOR_GREY, "* You are not authorized to use this!!");
	    
	new modelid,bone,Float:fX,Float:fY,Float:fZ,Float:fRX,Float:fRY,Float:fRZ;
	new comment[64];
 	if(sscanf(params, "iiffffffs", modelid, bone, fX,fY,fZ,fRX,fRY,fRZ,comment))
 	    return SendClientMessage(playerid, 0xFF6600FF,"Correct Usage: \"/attach <modelid> <bone> <x> <y> <z> <rotx> <roty> <rotz> <comment>\"");

	if(Attached[playerid] == 1)
	{
	    if(IsPlayerHoldingObject(playerid))
		{
	    	StopPlayerHoldingObject(playerid);
	    	SetPlayerHoldingObject(playerid, modelid, bone, fX,fY,fZ,fRX,fRY,fRZ);
		}
		else
		{
      		SetPlayerHoldingObject(playerid, modelid, bone, fX,fY,fZ,fRX,fRY,fRZ);
		}
	}
	else
	{
	    SetPlayerHoldingObject(playerid, modelid, bone, fX,fY,fZ,fRX,fRY,fRZ);
	    Attached[playerid] = 1;
	}

	printf("SetPlayerHoldingObject(playerid, %d,%d,%.01f,%.01f,%.01f,%.01f,%.01f,%.01f);", modelid, bone, fX,fY,fZ,fRX,fRY,fRZ);
	printf("Comment: %s",comment);
	return 1;
}
And here the /unattach command
Код:
dcmd_unattach(playerid, params[])
{
	#pragma unused params
    //if(PlayerInfo[playerid][pTester] != 3)
	//    return SendClientMessage(playerid, COLOR_GREY, "* You are not authorized to use this!!");
	if(Attached[playerid] == 1)
	{
		if(IsPlayerHoldingObject(playerid))
		{
		    StopPlayerHoldingObject(playerid);
		    Attached[playerid] = 0;
		}
		else
		{
		    Attached[playerid] = 0;
		}

	}
	else return SendClientMessage(playerid, 0xFF6600FF,"Error: Nothing is attached to you!");
	return 1;
}
Thx for any help.
Reply
#2

Since i have not received an answer in 2 Days, and it seems unlikely, someone reads this here if its on page 8, i think i can give it a little *push* without colliding to the rules?
Reply
#3

Use RemovePlayerAttachedObject. As far as I remember, the update for 0.3c introduced indexes for attached objects, simply use a for() loop to loop through every index and remove the object by the index.

I've written some pseudo-code for you to use (should work, but I haven't tested it and I haven't really used the object attaching functions yet):

pawn Код:
for(new i = 0; i < 5; i++) {
   RemovePlayerAttachedObject(playerid, i);
}
Reply
#4

Thanks, this wil certainy do it for the /unattach - But still i cant attach objects with the new 0.3c Command, my experiments with that failed, also cuz i wa snot able to add the 4 Variables (index, strech X strech Y and strecht Z)

maybe someone else can help me with this one, cuz removing an object is the one thing, but adding it is another^^
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)