Raised This Month: $51 Target: $400
 12% 

Giving Weapon After Spawn


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Gadzislaw007
Senior Member
Join Date: Nov 2009
Old 07-23-2010 , 08:46   Giving Weapon After Spawn
Reply With Quote #1

Hello there. Could anyone help me? I want to make that every player after spawn gets a weapon.
I know how to do this each roundstart, but when somebody join after the roundstart he won't get a weapon, so I want to make it at spawn.
Could anybody help me?

Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <cstrike>
#include <hamsandwich>
#include <engine>

#define PLUGIN "New Plugin"
#define VERSION "1.0"
#define AUTHOR "Author"

new zolnierz[33]
new medyk[33]
new ciezkozbrojny[33]
new zwiadowca[33]
new saper[33]


public plugin_init() {
	register_plugin(PLUGIN, VERSION, AUTHOR)
	
	register_clcmd("say /klasy", "mama");
	
	register_event("DeathMsg","hook_death","a");
	register_event("CurWeapon", "Bron", "be", "1=1");
	register_event("ResetHUD","newRound","b");
	RegisterHam(Ham_Spawn, "player", "Fw_PlayerSpawnPost", 1);
}


public client_authorized(id)
{
	zolnierz[id] = 0
	medyk[id] = 0
	ciezkozbrojny[id] = 0
	zwiadowca[id] = 0
	saper[id] = 0
	new los = random(4)
			client_print(id,print_chat,"Losuje klase")
	switch(los)
	{
		case 0:
		{
		zolnierz[id] = 1
		client_print(id,print_chat,"Jestes teraz zolnierzem.")
		}
		
		case 1:
		{ 
		client_print(id,print_chat,"Jestes teraz medykiem.")
		medyk[id] = 1
		}
		
		case 2:
		{ 
		client_print(id,print_chat,"Jestes teraz ciezkozbrojnym.")
		ciezkozbrojny[id] = 1
		}
		
		case 3:
		{ 
		client_print(id,print_chat,"Jestes teraz zwiadowca.")
		zwiadowca[id] = 1
		}
		
		case 4:
		{ 
		client_print(id,print_chat,"Jestes teraz saperem.")
		saper[id] = 1
		}
	}
}


	
public mama(id)
{
	if(!is_user_alive(id))
	{
	client_print(id,print_chat,"Poczekaj, az bedziesz zywy.")
	return PLUGIN_HANDLED
	}
					
	
new klasa_menu = menu_create("Wybierz klase", "golonka")
menu_additem(klasa_menu,"Zolnierz", "0", 0)
menu_additem(klasa_menu,"Medyk", "1", 0)
menu_additem(klasa_menu,"Ciezkozbrojny", "2", 0)
menu_additem(klasa_menu,"Zwiadowca", "3", 0)
menu_additem(klasa_menu,"Saper", "4", 0)

menu_setprop(klasa_menu, MPROP_EXIT, MEXIT_ALL);

menu_display(id,klasa_menu,0)
}

public golonka(id, menu, item)
{
	zolnierz[id] = 0
	medyk[id] = 0
	ciezkozbrojny[id] = 0
	zwiadowca[id] = 0
	saper[id] = 0


	user_silentkill(id);

	set_user_frags(id,get_user_frags(id))
	cs_set_user_deaths(id, get_user_deaths(id)-1)
	
		if( item == MENU_EXIT )
		{
			client_print(id,print_chat,"Nie to nie.")

		}
	
		else
		{
		new data[6], iName[64];
		new access, callback;
		menu_item_getinfo(menu, item, access, data,5, iName, 63, callback);
		new Losuj = str_to_num(data)
				switch(Losuj)
				{
					case 0:
					{ 
					client_print(id,print_chat,"Jestes teraz zolnierzem.")
					zolnierz[id] = 1
					}
					case 1:
					{ 
					client_print(id,print_chat,"Jestes teraz medykiem.")
					medyk[id] = 1
					}
					case 2:
					{ 
					client_print(id,print_chat,"Jestes teraz ciezkozbrojnym.")
					ciezkozbrojny[id] = 1
					}
					case 3:
					{ 
					client_print(id,print_chat,"Jestes teraz zwiadowca.")
					zwiadowca[id] = 1
					}
					case 4:
					{ 
					client_print(id,print_chat,"Jestes teraz saperem.")
					saper[id] = 1
					}
				}
		}
	
	
}

public hook_death()
{
	new victim = read_data(2);
	client_print(victim,print_chat,"Za chwilke dolaczysz do bitwy")
	set_task(4.0,"dolacz",victim);
	set_task(4.1,"dolacz",victim);
}


public dolacz(id)
{
	if(!is_user_alive(id))
{
ExecuteHam(Ham_CS_RoundRespawn,id)
}

}

public Fw_PlayerSpawnPost(id)
{
set_task(1,"give_wep",id)
}

public give_wep(id)
{
	strip_user_weapons(id)
	give_item(id, "item_suit")

	if(zolnierz[id])
		{
		
		set_user_health(id, 150)
		         give_item(id,"weapon_deagle")
			give_item(id,"ammo_50ae")
			give_item(id,"ammo_50ae")
			give_item(id,"ammo_50ae")
			give_item(id,"ammo_50ae")
			give_item(id,"ammo_50ae")
			give_item(id,"ammo_50ae")
			give_item(id,"ammo_50ae")
		}
	else if(medyk[id])
		{
		set_user_health(id, 100)
		         give_item(id,"weapon_glock18")
			give_item(id,"ammo_9mm")
			give_item(id,"ammo_9mm")
			give_item(id,"ammo_9mm")
			give_item(id,"ammo_9mm")
			give_item(id,"ammo_9mm")
			give_item(id,"ammo_9mm")
			give_item(id,"ammo_9mm")
			give_item(id,"ammo_9mm")
		}
		
	else if(zwiadowca[id])
		{
		set_user_health(id, 65)
		         give_item(id,"weapon_usp")
			give_item(id,"weapon_knife")
			give_item(id,"ammo_45acp")
			give_item(id,"ammo_45acp")
			give_item(id,"ammo_45acp")
			give_item(id,"ammo_45acp")
			give_item(id,"ammo_45acp")
			give_item(id,"ammo_45acp")
			give_item(id,"ammo_45acp")
			give_item(id,"ammo_45acp")
			give_item(id,"ammo_45acp")
		}
	else if(ciezkozbrojny[id])
		{
		set_user_health(id, 200)
		         give_item(id,"weapon_elite")
			give_item(id,"ammo_9mm")
			give_item(id,"ammo_9mm")
			give_item(id,"ammo_9mm")
			give_item(id,"ammo_9mm")
			give_item(id,"ammo_9mm")
			give_item(id,"ammo_9mm")
			give_item(id,"ammo_9mm")
			give_item(id,"ammo_9mm")
		}
	else
		{
		set_user_health(id, 110)
		         give_item(id,"weapon_fiveseven")
			give_item(id,"ammo_57mm")
			give_item(id,"ammo_57mm")
			give_item(id,"ammo_57mm")
			give_item(id,"ammo_57mm")
		}
	}
Well, I'm kinda stuck....

Last edited by Gadzislaw007; 07-23-2010 at 08:49.
Gadzislaw007 is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 07-23-2010 , 08:52   Re: Giving Weapon After Spawn
Reply With Quote #2

set_task(1,"give_wep",id)

The first parameter of set_task() should be a float.
set_task( 1.0 , "give_wep" , id )

The set_task is not needed at all, just call the function directly.
PHP Code:
public Fw_PlayerSpawnPost(id)
{
     if ( 
is_user_aliveid ) )
          
give_wepid );

__________________

Last edited by Bugsy; 07-23-2010 at 08:55.
Bugsy is offline
Gadzislaw007
Senior Member
Join Date: Nov 2009
Old 07-23-2010 , 09:02   Re: Giving Weapon After Spawn
Reply With Quote #3

Well, thanks for the help, but still not working.
Gadzislaw007 is offline
Peoples Army
SourceMod Donor
Join Date: Mar 2007
Old 07-23-2010 , 09:09   Re: Giving Weapon After Spawn
Reply With Quote #4

You can save yourself some lines and make your code more readable by using a loop to give ammo over and over


PHP Code:

for(i++)
{
    
give_item(id,"ammo_9mm");

__________________
Peoples Army is offline
Gadzislaw007
Senior Member
Join Date: Nov 2009
Old 07-23-2010 , 09:10   Re: Giving Weapon After Spawn
Reply With Quote #5

Well, thanks for that. But it's not the main problem, so I still can't go on.
Gadzislaw007 is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 07-23-2010 , 09:15   Re: Giving Weapon After Spawn
Reply With Quote #6

Well then you need to do some debugging on your givewep function.
__________________
Bugsy is offline
Gadzislaw007
Senior Member
Join Date: Nov 2009
Old 07-23-2010 , 09:49   Re: Giving Weapon After Spawn
Reply With Quote #7

It's not give_wep function problem, but it just does not 'catch' the Fw_PlayerSpawnPost...
If i attach give_wep for a command it works, but if i want Fw_PlayerSpawnPost to do something (even client_print) it does nothing.
Gadzislaw007 is offline
Peoples Army
SourceMod Donor
Join Date: Mar 2007
Old 07-23-2010 , 10:03   Re: Giving Weapon After Spawn
Reply With Quote #8

Get spawn using this method

http://forums.alliedmods.net/showthr...ighlight=spawn
__________________
Peoples Army is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 07-23-2010 , 10:04   Re: Giving Weapon After Spawn
Reply With Quote #9

It may be too early for a player to see a print the instant they are spawned. Try writing to the log file or set a players money/health/gravity. You have the correct method for hooking player spawn.
__________________
Bugsy is offline
Gadzislaw007
Senior Member
Join Date: Nov 2009
Old 07-23-2010 , 10:16   Re: Giving Weapon After Spawn
Reply With Quote #10

Like I said earlier, nothing happens. It just doesn't really see that function :/.
Gadzislaw007 is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 17:38.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode