Raised This Month: $ Target: $400
 0% 

How to get user's id?


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
KneeGrow
Junior Member
Join Date: Mar 2014
Old 03-09-2014 , 15:16   How to get user's id?
Reply With Quote #1

I gave pawn scripting my first shot but I'm struggling to understand about how to get a user's id from entering a command.
I was trying to write a code that will simply give you a shotgun by typing:
amx_giveshotgun <name> shotgun
Whenever I type in anything anywhere, it goes straight to printing to console
"you didn't type 'shotgun'"

The entire code is at the bottom.

Code:
public plugin_init(){
	register_plugin(PLUGIN,VERSION,AUTHOR);
	register_concmd("amx_giveshotgun","giveWeapon",ADMIN_KICK,"<target> <weaponid> enter 0-4");
}
public giveWeapon(id,key[]){
From what I know about defining methods, the parameters must be entered by the user. Which means, in this case, 'id' is just a variable. What I don't understand, or can't follow, is people somehow get the parameter id, to relate to the player initiating the command.

What do I do to set 'id' equal to the user's id so the method is returned to the right player?
I have looked at tutorials and other people's codes but none of them talk directly about getting a player's id

The code has no trouble compiling, but has trouble working.

Code:
#include <amxmodx>
#include <fun>
#include <amxmisc>

#define PLUGIN "giveWeapon"
#define VERSION "1.5"
#define AUTHOR "KneeGrow"

public plugin_init(){
	register_plugin(PLUGIN,VERSION,AUTHOR);
	register_concmd("amx_giveshotgun","giveWeapon",ADMIN_KICK,"<target> <weaponid> enter 0-4");
}
public giveWeapon(id,key[]){
	if(equali(key,"shotgun")){
		give_item(id,"weapon_shotgun");
		return PLUGIN_HANDLED;
	} else {
		console_print(id,"you didn't type 'shotgun'");
	}
	return PLUGIN_HANDLED;
	
}
and the way I've seen people deal with arrays has been hurting my brain since I'm used to reading java

Last edited by KneeGrow; 03-09-2014 at 15:21.
KneeGrow is offline
 



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 05:55.


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