On client_authorized i use the copy function to assign a weapon to a global variable with id as key.
PHP Code:
#include <amxmodx>
#include <cstrike>
#include <engine>
#include <fun>
#include <hamsandwich>
new g_iWep[33];
new g_iAmmo[33];
new const Weapon[][] =
{
"weapon_glock18",
"weapon_usp",
"weapon_p228",
"weapon_deagle",
"weapon_fiveseven",
"weapon_elite"
};
new const Ammo[][] =
{
"ammo_9mm",
"ammo_45acp",
"ammo_357sig",
"ammo_50ae",
"ammo_57mm"
};
public plugin_init()
{
register_plugin(Plugin, Version, Author);
RegisterHam(Ham_Spawn, "player", "fwHamPlayerSpawnPost", 1);
}
{...}
public client_authorized(id)
{
copy(g_iWep[id], charsmax(g_iWep), Weapon[0]);
copy(g_iAmmo[id], charsmax(g_iAmmo), Ammo[0]);
}
{...}
public fwHamPlayerSpawnPost(iPlayer)
{
if (is_user_alive(iPlayer))
{
give_item(iPlayer, g_iWep[iPlayer]);
give_item(iPlayer, g_iAmmo[iPlayer]);
}
}
{...}
If i print this in the same function then it displays properly as "weapon_glock18". Which is what I desire.
However, when trying to give the weapon to a player it does not always work.
I printed out in the server the player id and the weapon.
PHP Code:
Player ID: 1 (Wep: wweapon_glock18)
Player ID: 2 (Wep: weapon_glock18)
Player ID: 1 (Wep: wweapon_glock18)
Player ID: 2 (Wep: weapon_glock18)
Player ID: 1 (Wep: weapon_glock18)
Player ID: 1 (Wep: weapon_glock18)
Player ID: 2 (Wep: eapon_glock18)
Player ID: 1 (Wep: weapon_glock18)
Player ID: 2 (Wep: eapon_glock18)
__________________