AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved [HELP] Remember weapons (https://forums.alliedmods.net/showthread.php?t=308166)

CrAzY MaN 06-09-2018 03:54

[HELP] Remember weapons
 
How do i set weapons of killer and victim to previous weapons when they were respawned?

eg.
  • Current Weapon = ak47, glock18, knife
  • Died
  • On Respawn, change weapon to ak47, glock18, knife

HamletEagle 06-09-2018 04:14

Re: [HELP] Remember weapons
 
Save the weapons list in an array when they die and give it back to them on spawn.

CrAzY MaN 06-09-2018 06:30

Re: [HELP] Remember weapons
 
Can you show me example?

HamletEagle 06-09-2018 06:53

Re: [HELP] Remember weapons
 
https://forums.alliedmods.net/showthread.php?t=308093
Here is your example. Just make the array globals and index them by player index.

CrAzY MaN 06-18-2018 06:36

Re: [HELP] Remember weapons
 
Okay, so i tried making this.
It works fine, but gives some log errors.
Any fix?

Code:
Code:
#include <amxmodx> #include <cstrike> #include <fun> #include <fakemeta> #if AMXX_VERSION_NUM < 183     #include <dhudmessage> #endif   #define PLUGIN "Test:Remember Weapons on Respawn" #define VERSION "1.0" #define AUTHOR "CrAzY MaN"   new Array:g_weaponname;   public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR) }   public client_death(killer, victim) {     set_task(3.0, "respawn_player", victim)             set_dhudmessage(0, 255, 0, -1.0, 0.77, 0, 6.0, 12.0)     show_dhudmessage(victim, "You will respawn in 3 seconds.")         g_weaponname = ArrayCreate(32);         get_weapons(victim)         ArrayClear(g_weaponname) }   public get_weapons(id) {     new weapons[32], iWeapons, weapon_name[32];     get_user_weapons(id, weapons, iWeapons)       for (new i=0; i<=iWeapons; i++)     {               get_weaponname(weapons[i], weapon_name, charsmax(weapon_name))             ArrayPushString(g_weaponname, weapon_name)                 client_print(id, print_chat, "Old Weapons : %s", weapon_name)     } }   public give_weapons(id) {     new weapon_name[32];     strip_user_weapons(id)     for(new i=0; i < ArraySize(g_weaponname); i++ )     {         ArrayGetString(g_weaponname, i, weapon_name, charsmax(weapon_name))             give_item(id, weapon_name)                 client_print( id, print_chat, "New Weapons : %s", weapon_name )     } }   //----------------------------------------------------------------// /*-------------------------RESPAWN PLAYER-------------------------*/ //----------------------------------------------------------------//   public respawn_player(id) {     if (!is_user_connected(id) || is_user_alive(id) || cs_get_user_team(id) == CS_TEAM_SPECTATOR)         return;         set_pev(id, pev_deadflag, DEAD_RESPAWNABLE)     dllfunc(DLLFunc_Think, id)         if (is_user_bot(id) && pev(id, pev_deadflag) == DEAD_RESPAWNABLE)     {         dllfunc(DLLFunc_Spawn, id)     }         give_weapons(id) }

Error :
PHP Code:

L 06/18/2018 15:51:25Invalid weapon id 0
L 06
/18/2018 15:51:25: [AMXXDisplaying debug trace (plugin "Untitled.amxx"version "1.0")
L 06/18/2018 15:51:25: [AMXXRun time error 10native error (native "get_weaponname")
L 06/18/2018 15:51:25: [AMXX]    [0Untitled.sma::get_weapons (line 42)
L 06/18/2018 15:51:25: [AMXX]    [1Untitled.sma::client_death (line 29


^SmileY 06-18-2018 12:11

Re: [HELP] Remember weapons
 
You need to pick weapons to array at Ham_AddPlayerItem i guess, is better than store on death.
Also if possible spawn a player using Ham_CS_RoundRespawn

CrAzY MaN 06-18-2018 12:58

Re: [HELP] Remember weapons
 
I used Fakemeta everywhere in my plugin, don't wanna add another include for just this thing.
What am i doing wrong here?

^SmileY 06-18-2018 13:19

Re: [HELP] Remember weapons
 
Quote:

Originally Posted by CrAzY MaN (Post 2597748)
I used Fakemeta everywhere in my plugin, don't wanna add another include for just this thing.
What am i doing wrong here?

so forgot it, client_death is called after player dead soo get_user_weapons will not work

HamletEagle 06-18-2018 13:21

Re: [HELP] Remember weapons
 
Quote:

Originally Posted by CrAzY MaN (Post 2597748)
I used Fakemeta everywhere in my plugin, don't wanna add another include for just this thing.
What am i doing wrong here?

Not this bullshit again, not again..
Add as many includes as you need. By trying to use only one module you are doing way more harm than good.

CrAzY MaN 06-18-2018 13:36

Re: [HELP] Remember weapons
 
Okay, will mixup that.
But isn't there a way of doing this with DeathMsg or client_death?


All times are GMT -4. The time now is 04:35.

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