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