Post4VPS Forum | Free VPS Provider
[Help] I need help with a pickup - Printable Version

+- Post4VPS Forum | Free VPS Provider (https://post4vps.com)
+-- Forum: Geek World (https://post4vps.com/Forum-Geek-World)
+--- Forum: Scripting & Programming (https://post4vps.com/Forum-Scripting-Programming)
+--- Thread: [Help] I need help with a pickup (/Thread-Help-I-need-help-with-a-pickup)



[Help] I need help with a pickup - Hnewbie - 08-12-2019

Hello, I need you to help me in a pickup that I am doing, what I am doing is to create a pickup with the minigun icon and that when a player passes over the le of a minigun with 12 ammunition

I created the pickup with the minigun but when a player passes over it he doesn't give anything and I need help with that.

Here is the code I put:

new minigun;

///////////////////////////////////////////////////

public OnGameModeInit () {

minigun=CreatePickup (362, 1, 2489.5010, -1669.5480, 13.3359, 0);

return 1;
}

//////////////////////////////////////////////////// //

public OnPlayerPickUpPickup (playerid, pickupid)
{
if (pickupid == minigun)
{
GivePlayerWeapon (playerid, 362, 12);
}

return 1;
}


RE: [Help] I need help with a pickup - kbartek - 08-12-2019

Would be useful if you specified the game you are trying to code for. Noone will help you if we don't know what are you even coding for.


RE: [Help] I need help with a pickup - LightDestory - 08-14-2019

As said by @kbartek you must point out which game engine are you working on. Without this information we can't provide a proper help. Moreover, I suggest you to use services such as Pastebin or GitGists to share code snippets, they support specific-language formatting and styling that makes reading easier.

Regarding your problem, I think you need to handle the CollisionEvent between your PlayerEntity and your MinigunEntity, when it happens you just need to remove MinigunEntity from your Scene and do your things on PlayerEntity.

So, presuming you are using Unity, here some good articles about Collisions that can help you figure out how to properly handle them: I hope this will help you.


RE: [Help] I need help with a pickup - SRTerabytes - 08-14-2019

(08-12-2019, 11:57 AM)Hnewbie Wrote:  Hello, I need you to help me in a pickup that I am doing, what I am doing is to create a pickup with the minigun icon and that when a player passes over the le of a minigun with 12 ammunition

I created the pickup with the minigun but when a player passes over it he doesn't give anything and I need help with that.

Here is the code I put:

new minigun;

///////////////////////////////////////////////////

public OnGameModeInit () {

minigun=CreatePickup (362, 1, 2489.5010, -1669.5480, 13.3359, 0);

return 1;
}

//////////////////////////////////////////////////// //

public OnPlayerPickUpPickup (playerid, pickupid)
{
if (pickupid == minigun)
{
GivePlayerWeapon (playerid, 362, 12);
}

return 1;
}

For GivePlayerWeapon simply replace 362 with 38 and this script will work. You're using model id for weapon id which is incorrect. Take note of Weapons in the wiki. You'll be seeing a table with ID, Slot, and Model. The GivePlayerWeapon function takes ID from this table.


RE: [Help] I need help with a pickup - Hnewbie - 08-18-2019

(08-14-2019, 09:33 PM)SRTerabytes Wrote:  For GivePlayerWeapon simply replace 362 with 38 and this script will work. You're using model id for weapon id which is incorrect. Take note of Weapons in the wiki. You'll be seeing a table with ID, Slot, and Model. The GivePlayerWeapon function takes ID from this table.



Thanks yes that's what I did.and he is working thanks to those who reply to the post but this is okay but i thought it might be helpful to sa-mp.forum to solve my problem