AddPlayerItem & Ham_Item_Deploy

Сообщения
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 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;
}
 
Сообщения
443
Реакции
319
Помог
13 раз(а)
1605018380000.png


How do you think other users gave weapons to players at past, when reapi did not exist?
Do you think they had similar problems?

Reapi is needed (mostly) for guys like thephoenix who charge $10 just for replacing cs_get_user_armor with rg_get_user_armor and use the forum to sell their services (Я и PAWN | Изучаю, потому что интересно). Still don't know why they keep him on forum, he receives warnings for the same rule violations every time, warning multiplier should be introduced. More warning points for same types of rules violations.


Reapi solves the problem of stupidity for those places where technical knowledge is not required. It's hardcoded. You shouldn't use it everywhere.
Just open the native's description, everything is written there, can you open it? Okay. Let's pretend you can't open it.

Take give_item native from fun include.
The problem will repeat, right? So...
Pick up the weapon you just created on the map, the error will repeat itself, won't it?

Let's pretend that you still don't understand the core of the problem but you understand C/C++ (similar to pawn) or at least could read pseudocode, okay?

Let's open native src:

Let's move:

What do we see here?
The installation of the uid and created entity touch with the player, right? What happens if a player doesn't have a weapon? He will take it, right? Because power (weight in cs) of current weapon less than new one, this is how the cs works, most of goldsrc games likely work in same way.

Use the Advanced Ultimate Weapons or fantom grenade, there is one of the solutions to such problems (there are 3 possible solution).
The solution presented in these plugins is also correct.

Stop using @ instead public, it's for domes mf's, just useless. It's could produce more problems than solutions.
Why are you using iuser1 and not iuser2 and not iuser3 and not iuser4? It's not a questions, at least you are doing it in wrong way but im not gonna explain why, these are the problems of scripters like you and those people who will use this plugin.


Let's imagine that you went (Your car has mountain Dew, coz only real ass niggas drinks mountain dew, right?) to the store for spaghetti sauce for your grandma, bought 4 candies, spaghetti sauce, left the store and met your friend, gave him one of the candies.

You talked with a friend (and the candy has already been eaten).

You and a friend are thirsty (#nohomo).
You know that you have a drink in your car.
What about your friend, does he know? How would he know about this? No way, right? Knowing that, you can get rid of your thirsty after candy, but you need to tell your friend that you have a drink in the car, because still doesn't know bout it.

Probably to correct this situation - Before you give the candy, you need to say: Take the candy brother, I have a drink in the Car, if you want - tell me.
 
Сообщения
278
Реакции
137
Okay, lets answer like you do. Shel


Reapi solves the problem of stupidity for those places where technical knowledge is not required. It's hardcoded. You shouldn't use it everywhere.
Just open the native's description, everything is written there, can you open it? Okay. Let's pretend you can't open it.
I just used these commands from [ReAPI] Пример кастомного оружия с дополнительними свойствами And It works without any problems about models or something else.

Take give_item native from fun include.
The problem will repeat, right? So...
Pick up the weapon you just created on the map, the error will repeat itself, won't it?
Why the hell we are using give_item? There is no problem about rg_give_custom_item and it changes var_impulse of weapon. And I change weapon's skin with using that. No error anywhere.

Stop using @ instead public, it's for domes mf's, just useless. It's could produce more problems than solutions.
I have never had a problem yet.

Why are you using iuser1 and not iuser2 and not iuser3 and not iuser4? It's not a questions, at least you are doing it in wrong way but im not gonna explain why, these are the problems of scripters like you and those people who will use this plugin.

@CBasePlayerItem_Deploy_Deagle(const entity) {
Entity could be invalid, yes I know and I fixed it already.

Let's imagine that you went (Your car has mountain Dew, coz only real ass niggas drinks mountain dew, right?) to the store for spaghetti sauce for your grandma, bought 4 candies, spaghetti sauce, left the store and met your friend, gave him one of the candies.

You talked with a friend (and the candy has already been eaten).

You and a friend are thirsty (#nohomo).
You know that you have a drink in your car.
What about your friend, does he know? How would he know about this? No way, right? Knowing that, you can get rid of your thirsty after candy, but you need to tell your friend that you have a drink in the car, because still doesn't know bout it.

Probably to correct this situation - Before you give the candy, you need to say: Take the candy brother, I have a drink in the Car, if you want - tell me.
Instead, I removed all hudmessages and problem has been fixed. Thank you anyway for your necessary-unnecessary informations.
 
Сообщения
1,702
Реакции
1,512
Помог
26 раз(а)
Сообщения
443
Реакции
319
Помог
13 раз(а)
1605550553800.png

Or are you another one guy from Argentina/Turkey?

And It works without any problems about models or something else.
Is current topic is about models/something else problems? No. How it's related to this topic?


But at the first time you pick weapon, it shows Unknown (There's no owner).
And after that, you start talking about some unrelated bullshit, which doesn't help you solve the problem. Open fantom code, copypaste stock and use it as you wanna.

Why the hell we are using give_item? There is no problem about rg_give_custom_item and it changes var_impulse of weapon. And I change weapon's skin with using that. No error anywhere.

I didn't suggest to use give_item... Oh really? Why can't you figure out what is causing the problem then? You didn't read any bunch of problem related stuff from my msg, lol...


Did you expect a copy paste solution? Read forum description. There's no stuff like that.

1605550613400.png

Why are you replying me?
I have described to you the reason why this is happening.
Described how to fix it. Described where you could find the piece of code...

Have you tried to at least find fantom plugin? I guess no, right?
Why are you staying here if you can't read and understand the theory which describes core of the problem? Go to purchase section.





1605550271300.png


No comments, nice answer.

wopox1337 fantom steelzzz Garey medusa


Идите попытайтесь объяснить ему почему он ловит UB при попытке получить ид игрока из свойства оружия которое было выдано до того как он выставил ему свойства, постарайтесь при этом не словить отрицательную репутацию.


А, ну понятно, этот парень держит какой-то хостинг на котором продает плагины...
 
Последнее редактирование:
Сообщения
278
Реакции
137
Have you turned into a racist now? I read all things you said but you do not help me anymore because I do not have any problem about creating anything or finding the owner of weapon. Understand, I don't have any problem about weapon model/weapon vars... I just asked that Ham_Item_Deploy works before/after AddPlayerItem or (I was going to ask same question for Spawn)
In the first time player spawns, I give them Knife,Deagle and Awp and I give them an owner and show a hudmessage for information. Let me explain for deagle.

Player spawned
Gived deagle and set var_impulse for model.
Showed hudmessage (Ham_Item_Deploy)
AddItemPlayer (gived owner var_item1 etc)

I just wanted to change the order. If I set task for Ham_Item_Deploy to show hudmessage even 0.01, It work perfectly good. But I do not want to set task for each deploy.
 
Сообщения
443
Реакции
319
Помог
13 раз(а)
Read what racism means. It's about races.
I asked what country you are from to understand why you cannot open links and read the code.


I already answered you about iuser (same situation there with var_impulse), do you think members can only be used by you?
Do you think they were intended especially for using in a single plugin?
Why are you trying to reserve the commonly used members just for the one plugin?
We can't explain your mistakes to you.

You can't achive your purpose coz you are setting members after player get's weapon. It was described 10 times above.

No, I am actually not racist.
I'm black myself.

Blacker than a black hole.
I is a -
 
Сообщения
1,702
Реакции
1,512
Помог
26 раз(а)
Ugly hack: you can call ItemDeploy after give and set iuser1.
 
Сообщения
278
Реакции
137
I already answered you about iuser (same situation there with var_impulse)
I don't care how iuser works. I just copied these commands and used in my plugin cause I trust fl0wer's commands. If there was better way to take the owner of weapon, you could comment that post and I could have copied your commands.

do you think members can only be used by you?
Do you think they were intended especially for using in a single plugin?
Why are you trying to reserve the commonly used members just for the one plugin?
We can't explain your mistakes to you.
Wtf are you talking about here? I don't, don't and I am not trying it. Вопросы по созданию и модификации here is for questions and I ask a question. You don't have to answer. Nobody has to answer. Do not explain my mistake.

You can't achive your purpose coz you are setting members after player get's weapon. It was described 10 times above.
I set members with AddPlayerItem. How AddPlayerItem works after Ham_Item_Deploy? There is always a way to do it.

No, I am actually not racist.
I'm black myself.

Blacker than a black hole.
I ain't a black and ain't care what ur.
 
Сообщения
443
Реакции
319
Помог
13 раз(а)
Дальше сами объясняйте, он читать не умеет.
 
Сообщения
278
Реакции
137
Просто забудьте обо всем. Перестань отвечать. Без проблем.
 
Сообщения
1,702
Реакции
1,512
Помог
26 раз(а)

Пользователи, просматривающие эту тему

Сейчас на форуме нет ни одного пользователя.
Сверху Снизу