Raised This Month: $ Target: $400
 0% 

Console command registration not working.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
RSTFS
Junior Member
Join Date: Jan 2016
Old 01-09-2016 , 10:20   Console command registration not working.
Reply With Quote #1

This code works:
Code:
public void OnPluginStart(){
	RegConsoleCmd("sm_glock", GiveGlock);
}

public Action GiveGlock(int client, int args){
	if(IsPlayerAlive(client)){
		GivePlayerItem(client, "weapon_glock", 0);
	}
	return Plugin_Handled;
}
However, when I do anything related to removing weapons that the client already has, the command does not register. For example, this code does not work:
Code:
public void OnPluginStart(){
	RegConsoleCmd("sm_glock", GiveGlock);
}

public Action GiveGlock(int client, int args){
	if(IsPlayerAlive(client)){
		RemovePlayerItem(client, GetPlayerWeaponSlot(client, 0));         //This is the only line changed.
		GivePlayerItem(client, "weapon_glock", 0);
	}
	return Plugin_Handled;
}
0 warnings or errors during compilation.

Last edited by RSTFS; 01-09-2016 at 10:32.
RSTFS is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 01-09-2016 , 14:18   Re: Console command registration not working.
Reply With Quote #2

For issues with SourceMod code, post in the SourceMod forum.
__________________
fysiks is offline
RSTFS
Junior Member
Join Date: Jan 2016
Old 01-09-2016 , 16:15   Re: Console command registration not working.
Reply With Quote #3

Whoops, I don't see a way to delete this post though.
RSTFS is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 01-09-2016 , 16:57   Re: Console command registration not working.
Reply With Quote #4

Quote:
Originally Posted by RSTFS View Post
Whoops, I don't see a way to delete this post though.
Use the "Report Post" button on your first post and request it be removed.
__________________
fysiks is offline
Reply


Thread Tools
Display Modes

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 09:21.


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