Little help
#1

Hello,
I was trying to make something like attaching object to only one weapon, Heres the code it attaches the object but it dosn't Destroy it if i switch weapon, Please see if anything is wrong:

PHP код:
public OnPlayerUpdate(playerid)
{
    if(
GetPlayerWeapon(playerid)== 24)
    {
    
SetPlayerAttachedObject(playerid03399);
    }
    else
    {
    
DestroyObject(playerid0);
    }
    return 
1;

Reply
#2

You don't want to hook it into OnPlayerUpdate.

You should look at a timer, and check whether the object is needed before you keep processing the code.

Where you check for the deagle, should also check if the object is already spawned on the player. Via another variable, being ObjectSpawned[MAX_PLAYERS], and setting it when the object is spawned, and setting to 0 when the object is deleted.
Reply
#3

Can you give one example pls?
Reply
#4

You are entering wrong slot, you need to enter slot number 1 - 10, so for example:

SetPlayerAttachedObject(playerid, 5, 339, 9);

where 5 is the slot.

Then, replace DestroyObject(playerid, 0); with RemovePlayerAttachedObject(playerid, slot);, where slot is your entered number at SetPlayerAttachedObject.
Reply
#5

Quote:
Originally Posted by Bigwebicek
Посмотреть сообщение
You are entering wrong slot, you need to enter slot number 1 - 10, so for example:

SetPlayerAttachedObject(playerid, 5, 339, 9);

where 5 is the slot.

Then, replace DestroyObject(playerid, 0); with RemovePlayerAttachedObject(playerid, slot);, where slot is your entered number at SetPlayerAttachedObject.
Oh Man Thank you, It worked, Forgot the slots again ;c
I <3 you
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)