Участник
Пользователь
- Сообщения
- 278
- Реакции
- 137
Hi guys,
I made a plugin that let you change skins of weapons and shows owner's name and skin name of weapon but I got a problem.
When player spawns, i give them a weapon with
But at the first time you pick weapon, it shows Unknown (There's no owner). I added
Some commands of plugins;
I made a plugin that let you change skins of weapons and shows owner's name and skin name of weapon but I got a problem.
When player spawns, i give them a weapon with
rg_give_custom_item
and change var_iuser1 because the owner. Then I show hudmessage with deploy.But at the first time you pick weapon, it shows Unknown (There's no owner). I added
set_task
before showing hudmessage (0.1), it works but i really don't want to create task because needless.Some commands of plugins;
Код:
/* The weapon skin's name and model name btw. */
new const deaglemodels[][] = {
"defaultdeagle", "cobaltdisruption", "codered", "directive", "kumichodragon", "blazev1",
};
RegisterHookChain(RG_CBasePlayer_Spawn, "@CBasePlayer_Spawn", .post = true);
RegisterHam(Ham_Item_Deploy, "weapon_deagle", "@CBasePlayerItem_Deploy_Deagle", .Post = true);
@CBasePlayer_Spawn(const id) {
if(!is_user_alive(id)) {
return;
}
if(!rg_has_item_by_name(id, "weapon_deagle")) {
return;
}
// g_deagle[id] is the weapon skin he/she picked. It is 0,1,2,3,4,5... I did it with new const etc. whatever
new entity = rg_give_custom_item(id, "weapon_deagle", GT_APPEND, g_deagle[id]);
set_entvar(entity, var_iuser1, get_user_userid(id) + UNQUEID);
}
@CBasePlayerItem_Deploy_Deagle(const entity) {
new Uid = get_entvar(entity, var_impulse);
new id = get_member(entity, m_pPlayer);
SetModels(deaglemodels[Uid], id);
/* It shows unknown...
set_hudmessage(255, 42, 42, 10.9, 0.75, 0, 0.0, 999.0);
ShowSyncHudMsg(id, syncObj, "Weapon: Deagle^nWeapon Owner: %s^nWeapon Model: %s", TheOwnerOfWeapon(entity, id), TheModelOfWeapon(entity, 1));
*/
new tdData[TaskData];
tdData[pPlayerIndex] = id;
tdData[pEntityIndex] = entity;
set_task(0.1, "@DeagleHud", id, tdData, sizeof(tdData));
}
@DeagleHud(tdInComing[TaskData], TaskId) {
new id = tdInComing[pPlayerIndex];
new entity = tdInComing[pEntityIndex];
set_hudmessage(255, 42, 42, 10.9, 0.75, 0, 0.0, 999.0);
ShowSyncHudMsg(id, syncObj, "Weapon: Deagle^nWeapon Owner: %s^nWeapon Model: %s", TheOwnerOfWeapon(entity, id), TheModelOfWeapon(entity, 1));
}
/* It is needless for fixing that problem but whatever I wrote. */
TheOwnerOfWeapon(const pItem, const pPlayer) {
new dontKnowWhat = get_entvar(pItem, var_iuser1);
static piId, szName[MAX_NAME_LENGTH];
piId = dontKnowWhat - UNQUEID;
if(get_user_userid(pPlayer) == piId) {
formatex(szName, charsmax(szName), "%n", pPlayer);
return szName;
}
for(new i = 1; i <= MAX_CLIENTS; i++) {
if(get_user_userid(i)==piId && is_user_connected(i)) {
get_user_name(i, szName, charsmax(szName));
return szName;
}
}
formatex(szName, charsmax(szName), "Bilinmiyor");
return szName;
}
TheModelOfWeapon(const pItem, const weapon) {
new Uid = get_entvar(pItem, var_impulse);
new text[64];
switch(weapon) {
case 1: {
formatex(text, charsmax(text), "%s", deaglemodels[Uid]);
}
//... I deleted others cause needless
}
return text;
}