Raised This Month: $230 Target: $400
 57% 

Help about showing current ammo packs


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Ali0mer
Member
Join Date: Jan 2016
Location: Iraq
Old 05-11-2019 , 11:08   Help about showing current ammo packs
Reply With Quote #1

hey guys, finally i decided to learn pawn language
anyway i need your help to do something

First im trying to make a plugin for zombie plague that shows the current ammo packs

look here what i did in this code
Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <zombieplague>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"

new g_ammopacks [33]

public plugin_init() {
	register_plugin(PLUGIN, VERSION, AUTHOR)
	
	register_clcmd("say /mypacks", "mypackshow")
}

public mypackshow(iPlayer)
{
	if (is_user_connected(iPlayer))
{
		client_print(iPlayer, print_chat, "Your Ammo Packs is : %d", g_ammopacks)
	}
}
It returns 0 which its true right?

Can you tell me how to show the current ammo packs? just a example code so i could learn

Thank you

EDIT:
I think i solved it
By doing this
Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <zombieplague>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"


public plugin_init() {
	register_plugin(PLUGIN, VERSION, AUTHOR)
	
	register_clcmd("say /mypacks", "mypackshow")
}

public mypackshow(iPlayer)
{
	new Ammo
	
	if (is_user_connected(iPlayer))
		{
			Ammo = zp_get_user_ammo_packs(iPlayer)
			
			client_print(iPlayer, print_chat, "Your Ammo Is : %d", Ammo)
		}
	}
So thats right?

Last edited by Ali0mer; 05-11-2019 at 11:28.
Ali0mer is offline
Send a message via Skype™ to Ali0mer
<VeCo>
Veteran Member
Join Date: Jul 2009
Location: Bulgaria
Old 05-11-2019 , 11:51   Re: Scripting Help
Reply With Quote #2

Yeah, that's why the zombieplague library exists.
Just to note, you don't need the is_user_connected check in mypackshow, a player can't write the command if he isn't in the server anyway.
__________________

Last edited by <VeCo>; 05-11-2019 at 11:52.
<VeCo> is offline
Ali0mer
Member
Join Date: Jan 2016
Location: Iraq
Old 05-11-2019 , 11:55   Re: Scripting Help
Reply With Quote #3

Quote:
Originally Posted by <VeCo> View Post
Yeah, that's why the zombieplague library exists.
Just to note, you don't need the is_user_connected check in mypackshow, a player can't write the command if he isn't in the server anyway.
Hii thank you for the note

Im still new to this and thank you again!
Ali0mer is offline
Send a message via Skype™ to Ali0mer
thEsp
Veteran Member
Join Date: Aug 2017
Old 05-11-2019 , 13:15   Re: Scripting Help
Reply With Quote #4

As VeCo said, there's no need for that check. Instead it would be better to check if player is alive, since players can't have ammo once they're dead, same goes for zp right?
thEsp is offline
Ali0mer
Member
Join Date: Jan 2016
Location: Iraq
Old 05-11-2019 , 17:08   Re: Scripting Help
Reply With Quote #5

Quote:
Originally Posted by thEsp View Post
As VeCo said, there's no need for that check. Instead it would be better to check if player is alive, since players can't have ammo once they're dead, same goes for zp right?
Yeah if they r dead, they cant use them but they wont lose them too
So it depends on author if he wants to enable the cmd on alive or dead

Last edited by Ali0mer; 05-11-2019 at 17:09.
Ali0mer is offline
Send a message via Skype™ to Ali0mer
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 05-11-2019 , 18:15   Re: Scripting Help
Reply With Quote #6

Quote:
Originally Posted by thEsp View Post
As VeCo said, there's no need for that check. Instead it would be better to check if player is alive, since players can't have ammo once they're dead, same goes for zp right?
It's ammo packs, not ammo. They work like money in ZP, so people CAN have them while dead. There's no need for that check.

What I would advice you is to use a proper title for your thread. Posting a thread named "Scripting Help" in the section "Scripting Help" is pretty much useless. The title needs to describe the thread as much as possible.

You don't need <amxmisc> in the code.

The "Ammo" variable is not needed either if you're going to use it only once. You can use the "zp_get_user_ammo_packs" function directly in "client_print".

You can use "return PLUGIN_HANDLED" in the end of the function if you want to hide the "/mypacks" command from showing in chat.
__________________


Dear admins. If somehow you managed to read this, plz fix.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Old 05-12-2019, 05:05
thEsp
This message has been deleted by thEsp. Reason: nvm thread possibly got solved
Reply


Thread Tools
Display Modes

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 00:26.


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