SA-MP Forums Archive
Pickup with keys - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Pickup with keys (/showthread.php?tid=460555)



Pickup with keys - SilentSoul - 29.08.2013

Hello guys, i want to know how to make pickup work by key "Alt" i have found there some keys will help me https://sampwiki.blast.hk/wiki/Keys

Okay so for example i wanna add armour
pawn Код:
new pickup;
In the top of script And
pawn Код:
pickup = CreatePickup(1242, 2, Float:x, Float:y, Float:z, -1);
I want the player only get his armour if he press alt on the pickup
Thanks!,sorry for my bad english.


Re: Pickup with keys - urbanghetto - 29.08.2013

You don't need to create a Pickup to give armour to the player, the Alt key corresponds to the Walk key by default so here is the code put this somewhere in your script :

Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
	if (newkeys & KEY_WALK) // If the player presses the Walk key (by default Alt)
	{
		SetPlayerArmour(playerid,100);
	}
	return 1;
}



Re: Pickup with keys - SilentSoul - 29.08.2013

Thank you for reply but i mean something else , i mean to add pickup in game but when
pawn Код:
public OnPlayerPickUpPickup(playerid, pickupid)
{
    return 1;
}
He will automatically refund his armour i don't want this i want to add by Key "alt" to refund his armour
Thanks.


Re: Pickup with keys - SilentSoul - 29.08.2013

Thanks guys , i already created |admins can delete my topic


Re: Pickup with keys - urbanghetto - 29.08.2013

pawn Код:
new PickedArmour[MAX_PLAYERS]; // At the top of your GM

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if (newkeys & KEY_WALK) // If the player presses the Walk key (by default Alt)
    {
        if(PickedArmour[playerid] == 1){
            SetPlayerArmour(playerid,100);
            PickedArmour[playerid] = 0;
        }
    }
    return 1;
}

public OnPlayerPickUpPickup(playerid, pickupid)
{
    if (pickupid == pickup){
        PickedArmour[playerid] = 1;
    }
    return 1;
}



Re: Pickup with keys - SilentSoul - 29.08.2013

Thank you