PDA

View Full Version : Automatic give granate


Pach0nkata
01-25-2017, 12:00
Hello, i serch for auto give granate after 10 second i will use for respawn server. thank you and sorry i don't speak good english.

OciXCrom
01-25-2017, 12:42
After 10 seconds of what?

Pach0nkata
01-25-2017, 12:45
After 10 seconds of what?
After 10 secods to give grande free, and after u use it to give again after 10 seconds.

Relaxing
01-25-2017, 13:57
I believe that should do it...

#include < amxmodx >
#include < fun >

new gMaxPlayers;

public plugin_init( )
{
gMaxPlayers = get_maxplayers( );

set_task( 10.0, "ActionGiveGrenade", _, _, _, "b" );
}

public ActionGiveGrenade( )
{
for(new i = 0; i < gMaxPlayers; i++)
{
if ( is_user_alive( i ) )
{
give_item( id, "weapon_hegrenade" )
}
}
}

Pach0nkata
01-25-2017, 15:23
Can you add message in the screen you will get granade after 10,9,8,... and if u use granade to screen add wait 10 seconds to give you granade
Granade respawn after 10,9,8,...

edon1337
01-25-2017, 16:27
Since when is plugin_init used as a Respawn event ?

@pach you want it to give grenades after 10 seconds of respawn ?

EFFx
01-25-2017, 19:32
#include < amxmodx >
#include < fun >

new gMaxPlayers;

public plugin_init( )
{
gMaxPlayers = get_maxplayers( );

set_task( 10.0, "ActionGiveGrenade", _, _, _, "b" );
}

public ActionGiveGrenade( )
{
for(new i = 0; i < gMaxPlayers; i++)
{
if ( is_user_alive( i ) )
{
give_item( id, "weapon_hegrenade" )
}
}
}

Holy sh*t Relaxing, this code is amazing.

HamletEagle
01-26-2017, 01:24
Since when is plugin_init used as a Respawn event ?

@pach you want it to give grenades after 10 seconds of respawn ?

Where do you see that? What he did is fine.

edon1337
01-26-2017, 06:09
What he did is fine.

Totally.

1. He said 10 seconds after respawn and he set the task on plugin_init.
2. He made a new variable i as the index and used an undefined symbol "id" on give_item.

Relaxing
01-26-2017, 06:33
It's a quote peeps. Don't get made at me.

OciXCrom
01-26-2017, 08:25
1. He said 10 seconds after respawn and he set the task on plugin_init.

He never said after respawn. He actually never said when, so that's why I asked WHEN. He messaged me on Skype and said that he wants it every time he throws a grenade.

edon1337
01-26-2017, 08:44
Then use grenade_throw from csx?

HamletEagle
01-26-2017, 13:22
Totally.

1. He said 10 seconds after respawn and he set the task on plugin_init.
2. He made a new variable i as the index and used an undefined symbol "id" on give_item.

I was refering only to what I quoted. There plugin_init was not used as a spawn event, but to create a single task and loop all players instead of creating 32 individual tasks, which is good practice. I don't know what OP wants, I just told you that doing that is not wrong.

Relaxing
01-26-2017, 16:39
Try, I changed somethings, btw it's UNTESTED

#include <amxmodx>
#include <fun>

#define TASK_GRENADE 418471894

new g_msgHud;

public plugin_init()
g_msgHud = CreateHudSyncObj();

public client_putinserver(id)
{
if (!is_user_alive(id))
return;

new Float:time = 10.0;

static msg[128];
formatex(msg, charsmax(msg), user_has_weapon(id, CSW_HEGRENADE) ? "You already have He Grenade" : "HE Grenade after %i secondes", time);

set_hudmessage(0, 150, 100, 0.05, 0.17, 0, 6.0, 1.1, 0.0, 0.0, -1);
ShowSyncHudMsg(id, g_msgHud, "%s", msg);

remove_task(TASK_GRENADE);
set_task(time, "task_GiveGrenade", id+TASK_GRENADE, _, _, "b");
}

public task_GiveGrenade(id)
{
id -= TASK_GRENADE;

if (user_has_weapon(id, CSW_HEGRENADE))
return;

give_item(id, "weapon_hegrenade");
}

I suggest you to use Connor's one if this doesn't work
After a quick search...