Raised This Month: $51 Target: $400
 12% 

About A Plugin That Compiled Successfully but Doesn't Work


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Jess98
Junior Member
Join Date: Apr 2018
Old 12-19-2018 , 06:45   About A Plugin That Compiled Successfully but Doesn't Work
Reply With Quote #1

Hi, I have made a simple plugin which gives ammo packs to players who use the valid nicknames that I wrote when they connect server. As I said in the title, it compiled without any errors. I also tried it with the forward "client_putinserver()" but still same. What's wrong with this?

Code:
#include <amxmodx>
#include <zombieplague>

#define PLUGIN "Giving Ammo Packs When Valid Nicknames Perception"
#define VERSION "1.0"
#define AUTHOR "Jess"

public plugin_init() {

       register_plugin(PLUGIN, VERSION, AUTHOR)

       register_clcmd("say /sil", "Event_Of_Remove_Ammo_Packs")
       register_clcmd("say /sil", "Event_Of_Remove_Ammo_Packs")
}

public client_connect(ID) {

       new Get_Player_Name[32]
       get_user_name(ID, Get_Player_Name, charsmax(Get_Player_Name))

       if(equali(Get_Player_Name, "Alex"))
       {
              client_print_color(ID, ID, "^4Hey, welcome to the server. You have got ^399999 Ammo Packs. ^4Enjoy the game!")
              client_print_color(ID, ID, "^4Hey, welcome to the server. You have got ^399999 Ammo Packs. ^4Enjoy the game!")
              client_print_color(ID, ID, "^4Hey, welcome to the server. You have got ^399999 Ammo Packs. ^4Enjoy the game!")

              zp_set_user_ammo_packs(ID, zp_get_user_ammo_packs(ID) + 99999)
       }
          
       else if(equali(Get_Player_Name, "Kevin"))
       {
              client_print_color(ID, ID, "^4Hey, welcome to the server. You have got ^399999 Ammo Packs. ^4Enjoy the game!")
              client_print_color(ID, ID, "^4Hey, welcome to the server. You have got ^399999 Ammo Packs. ^4Enjoy the game!")
              client_print_color(ID, ID, "^4Hey, welcome to the server. You have got ^399999 Ammo Packs. ^4Enjoy the game!")

              zp_set_user_ammo_packs(ID, zp_get_user_ammo_packs(ID) + 99999)
       }
}

public Event_Of_Remove_Ammo_Packs(ID) {

       zp_set_user_ammo_packs(ID, zp_get_user_ammo_packs(ID) - 97000)
}

Last edited by Jess98; 12-19-2018 at 09:38. Reason: Edited an error
Jess98 is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 12-19-2018 , 06:53   Re: A Plugin That Compiles Successful but Doesn't Work
Reply With Quote #2

There is nothing strange in a compiled plugin that doesn't work. If everything is written as it should for the computer to read, it doesn't mean the in-game logic is correct as well.

client_connect is called when the player is still connecting, so he can't possibly see the chat message. Try using client_putinserver and/or a 1-2 seconds task to delay the function.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Jess98
Junior Member
Join Date: Apr 2018
Old 12-19-2018 , 08:45   Re: About A Plugin That Compiled Successfully but Doesn't Work
Reply With Quote #3

Quote:
Originally Posted by OciXCrom View Post
There is nothing strange in a compiled plugin that doesn't work. If everything is written as it should for the computer to read, it doesn't mean the in-game logic is correct as well.

client_connect is called when the player is still connecting, so he can't possibly see the chat message. Try using client_putinserver and/or a 1-2 seconds task to delay the function.
I knew it already, I didn't mean that if a plugin compiled without any error then it works as successful in the game while writing the title of this subject. And, I tried "client_putinserver()" before but it didn't work as I said on the top.

Shortly before, changed the if queries as

if(is_user_connected(ID) && equali(Get_Player_Name, "Alex"))
else if(is_user_connected(ID) && equali(Get_Player_Name, "Kevin"))

with using the forward "client_connect()" but still same. I'll try to use set_task when I have time to look at this problem.
Jess98 is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 12-19-2018 , 14:12   Re: About A Plugin That Compiled Successfully but Doesn't Work
Reply With Quote #4

There's no point in checking if the user is connected in those forwards. If they were called, the user is 100% connected.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 12-19-2018 , 20:42   Re: About A Plugin That Compiled Successfully but Doesn't Work
Reply With Quote #5

How do you expect to give ammo to a player that isn't 1) on a team and 2) alive? Is there something strange about ZombiePlague that makes it actually work that way?
__________________
fysiks is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 12-20-2018 , 08:41   Re: About A Plugin That Compiled Successfully but Doesn't Work
Reply With Quote #6

Quote:
Originally Posted by fysiks View Post
How do you expect to give ammo to a player that isn't 1) on a team and 2) alive? Is there something strange about ZombiePlague that makes it actually work that way?
It's not ammo, it's ammo packs. They work like credits/money, so there's no reason for the player to be alive or in a team.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
iceeedr
Veteran Member
Join Date: Apr 2017
Location: Brazil
Old 12-20-2018 , 09:58   Re: About A Plugin That Compiled Successfully but Doesn't Work
Reply With Quote #7

The problem can be in the check of the name, for example create a const with the steamids, and check the putin server if get_user_authid is equal to const [i], it is not difficult and it is a better method ...
__________________


Quote:
Originally Posted by fysiks View Post
Please stop trying to help. You appear to just be posting random stuff. Wait until you actually understand more about AMX Mod X and how the game works.
https://iceeedr.com.br/
iceeedr is offline
Send a message via Skype™ to iceeedr
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 12-20-2018 , 17:54   Re: About A Plugin That Compiled Successfully but Doesn't Work
Reply With Quote #8

The best way probably would be in client_authorized instead of client_connect or client_putinserver.
__________________








CrazY. is offline
LondoN
Senior Member
Join Date: Dec 2015
Location: Roman, Romania.
Old 12-21-2018 , 12:25   Re: About A Plugin That Compiled Successfully but Doesn't Work
Reply With Quote #9

Code:
#include < amxmodx >

native zp_set_user_ammo_packs ( Player, Packs );
native zp_get_user_ammo_packs ( Player );

new const szNames [ ] [ ] = 
{
	"Alex",
	"Kevin"
};

new g_PlayerName [ 33 ] [ 32 ];

const Size = sizeof szNames;

public plugin_init ( )	register_clcmd ( "say /sil", "RemovePacks" );
public RemovePacks ( id )
{
	for ( new i = 0; i < Size; i++ )
	{
		if ( equal ( g_PlayerName [ id ], szNames [ i ] ) )
			zp_set_user_ammo_packs ( id, zp_get_user_ammo_packs ( id ) - 97000 );
	}
}

public client_putinserver ( id )
{
	if ( is_user_bot ( id ) || is_user_hltv ( id ) )
		return;

	get_user_name ( id, g_PlayerName [ id ], charsmax ( g_PlayerName ) );

	set_task ( 1.0, "GivePlayerPacks", id );
}

public GivePlayerPacks ( id )
{
	for ( new i = 0; i < Size; i++ )
	{
		if ( equal ( g_PlayerName [ id ], szNames [ i ] ) )
		{
			zp_set_user_ammo_packs ( id, 99999 );
			client_print ( id, print_chat, "[ZP] Hey, welcome to the server. You have got 99999 Ammo Packs" );
		}
	}
}
If you want to give packs to multiple names, my oppinion is .. the loop is the best way..and the client_putinserver is the perfect forward to execute. Otherwise at /sil you need to check names again .. else all players can remove packs and will be -1, -2 ammo packs per id.
__________________
LondoN is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 21:31.


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