AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [FUN] Invalid player 2 on my script =/ (https://forums.alliedmods.net/showthread.php?t=24901)

o0panda 03-04-2006 15:33

[FUN] Invalid player 2 on my script =/
 
Hi guys,

I made a plugin for fy_ maps for my server alone that drops their glock and usp and replace it with a deagle. It works perfectly, just that if I don't add "debug" in plugins.ini it gives me this error:

Quote:

L 03/04/2006 - 13:22:57: [FUN] Invalid player 2
L 03/04/2006 - 13:22:57: [AMXX] Run time error 10 (plugin "drop_give.amxx") - debug not enabled!
L 03/04/2006 - 13:22:57: [AMXX] To enable debug mode, add "debug" after the plugin name in plugins.ini (without quotes).
I add debug, but no errors come up. :S I just want it to run smooth without having to debug.

Here's the code:
Code:
#include <amxmodx> #include <fun> #include <cstrike> new givedeagle = 0; public plugin_init() {   register_plugin("Drop&Give", "1.0", "PandaGirl")   register_event("ResetHUD", "spawned", "b")   new mapname[33]   get_mapname(mapname,32)   if(containi(mapname,"fy_") > -1 ) {     givedeagle = 1;     } } public spawned(id) {         if(givedeagle == 1 && is_user_alive(id)) {     client_cmd(id, "drop weapon_glock18")     client_cmd(id, "drop weapon_usp")     set_task(0.5,"give_it",id)     } } public give_it(id) {         give_item(id,"weapon_deagle")     cs_set_user_bpammo(id, CSW_DEAGLE, 56) }

Jordan 03-04-2006 16:04

I'm not positive, but I believe it could be that there aren't two people on the server - one with a glock and one with a usp. Plus, ResetHUD occurs at user spawn or at the very end of the round (at least that's my understanding of it). I could be wrong of cours, but I would try this:

Code:
#include <amxmodx> #include <fun> #include <cstrike> new givedeagle = 0; new g_szWeapon[] = //our weapon category {     "weapon_glock18",     "weapon_usp" } public plugin_init() {     register_plugin("Drop&Give", "1.0", "PandaGirl")     register_event("ResetHUD", "spawned", "b")     new mapname[33]     get_mapname(mapname,32)     if(containi(mapname,"fy_") > -1 )     {         givedeagle = 1;     } } public spawned(id) {           if(givedeagle == 1) //no if(user_is_alive(id)) is needed since this is at spawn event     {         set_task(0.5, "give_it", id) //just so it doesn't clutter the event     } } public give_it(id) {           client_cmd(id, "drop", g_szWeapon) //drops either of the weapons in our weapon category     give_item(id, "weapon_deagle")     cs_set_user_bpammo(id, CSW_DEAGLE, 56)     return PLUGIN_CONTINUE }

Optionally you can try this, but I think the first one shoudl work:

Code:
#include <amxmodx> #include <fun> #include <cstrike> #define MAX_SECONDARY 2 new g_szWeapon[MAX_SECONDARY][] = //our weapon category {     "weapon_glock18",     "weapon_usp" } new givedeagle = 0; new bool:g_bSecondary[33]; //-------------------------------------------------------------------------------- public plugin_init() {     register_plugin("Drop&Give", "1.0", "PandaGirl")     register_event("ResetHUD", "spawned", "b")     register_event("CurWeapon", "Check_Weapon", "be", "2!0")     new mapname[33]     get_mapname(mapname,32)     if(containi(mapname,"fy_") > -1 )     {         givedeagle = 1;     } } //-------------------------------------------------------------------------------- public Check_Weapon(id) //checks if they have either weapon {     new clip, ammo, weapon = get_user_weapon(id,clip,ammo);     new szWeapName[33];     get_weaponname(weapon, szWeapName, 32);       g_bSecondary[id] = false;     for(new i = 0; i < MAX_SECONDARY; i++)     {         if(equali(szWeapName, g_szWeapon[i]))         g_bSecondary[id] = true;     }     if(!g_bSecondary[id])     {         for(new i = 0; i < MAX_SECONDARY; i++)         {             if(equali(szWeapName, g_szWeapon[i]))             client_cmd(id, "%s", g_szWeapon[i])             return PLUGIN_CONTINUE         }     }     return PLUGIN_CONTINUE } //-------------------------------------------------------------------------------- public spawned(id) {           if(givedeagle == 1) //no if(user_is_alive(id)) is needed since this is at spawn event     {         set_task(0.5, "give_it", id) //just so it doesn't clutter the event     } } //-------------------------------------------------------------------------------- public give_it(id) {           client_cmd(id, "drop", g_szWeapon) //drops either of the weapons in our weapon category     give_item(id, "weapon_deagle")     cs_set_user_bpammo(id, CSW_DEAGLE, 56)     return PLUGIN_CONTINUE }

teame06 03-04-2006 16:47

@ ^_^Satan^_^

You should be checking if the player is alive to. Because ResetHud is called more often then you think. It called after putinserver when the client join

Jordan 03-04-2006 16:49

teame06 is smart. Put the is_user_alive thing back in :P

o0panda 03-04-2006 17:03

Lol, ok ^^ Thanks, I'll try it out.

edit:

Well it works fine, no errors, but now it drops my glock then gives me deagle, then drops it, and give me another glock. o.o I'll check and see if I can get it working. I used the first code btw by satan.

edit2:

I made my original script work by using an if and else statement in between the drop cmds. Now it works, and even better, it doesn't give players who did'nt die last round a new deagle on start of new round. ^^

Thx for the effort. +Karma.


All times are GMT -4. The time now is 20:25.

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