AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Help about showing current ammo packs (https://forums.alliedmods.net/showthread.php?t=316171)

Ali0mer 05-11-2019 11:08

Help about showing current ammo packs
 
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?

<VeCo> 05-11-2019 11:51

Re: Scripting Help
 
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.

Ali0mer 05-11-2019 11:55

Re: Scripting Help
 
Quote:

Originally Posted by <VeCo> (Post 2651215)
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!

thEsp 05-11-2019 13:15

Re: Scripting Help
 
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?

Ali0mer 05-11-2019 17:08

Re: Scripting Help
 
Quote:

Originally Posted by thEsp (Post 2651229)
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

OciXCrom 05-11-2019 18:15

Re: Scripting Help
 
Quote:

Originally Posted by thEsp (Post 2651229)
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.


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

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