AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Approved Plugins (https://forums.alliedmods.net/forumdisplay.php?f=8)
-   -   Buy Zoom v1.2.4 (https://forums.alliedmods.net/showthread.php?t=86429)

fezh 02-25-2009 14:24

Buy Zoom v1.2.4
 
2 Attachment(s)
.: Description :.
With this plugin, players can buy the AUG's zoom on any weapon (and remove it) with two short commands. After the player dies or the round ends, it is automatically removed.

.: Commands :.
say /zoom - Set zoom on player.
say /remove - Remove the zoom.

.: CVAR :.
amxx_zoom_cost "500" // Set the zoom cost (default 500).

.: Installation :.
Extract .amxx file to your plugins folder, and add its name to plugins.ini
For the proper functioning of the plugin, download the Multilingual File (.txt) and put it in data\lang.

.: Changelog :.
Code:

v1.0 - First release.
v1.1 - Added multilingual support.
v1.2 - Fixed small bug when you die and added a help motd.
v1.2.1 - Fixed again the death's bug, optimization of the code (thanks Exolent) and added some minor stuff. Also, fixed the Spanish translation, because I wrote bad (duh).
v1.2.2 - Plugin updated by joaquimandrade's way.
v1.2.3 - Removed useless stuff.
v1.2.4 - Fixed ML functions, all thanks to arkshine & danielkza.

.: Misc Stuff :..: Download :.

crazyeffect 02-25-2009 14:33

Re: Buy Zoom
 
Good idea :D

+k


It doesnt matter, but why is there a

PHP Code:

#define ZOOMMSG "You have bought Zoom!" 

If you also can do:

PHP Code:

        client_print(idprint_chat"[AMXX] You have bought Zoom!"

(With the other 2 msg's too :D)

And maybe you could make it multilang :D

fezh 02-25-2009 15:13

Re: Buy Zoom
 
Because my way is more useful for users who have a little-know scripting or simply nothing.

minimiller 02-25-2009 15:16

Re: Buy Zoom
 
why not make it ML?
then ppl can change the ML file rather than edit the source and recompile
nice plugin (Y)

crazyeffect 02-26-2009 09:03

Re: Buy Zoom
 
2 Attachment(s)
Quote:

Originally Posted by fezh (Post 768955)
Because my way is more useful for users who have a little-know scripting or simply nothing.

This is way easier :D

fezh 02-26-2009 10:58

Re: Buy Zoom
 
Quote:

Originally Posted by crazyeffect (Post 769409)
This is way easier :D

Yea, but my plugin doesn't get warnings on compilation..
Code:

/home/groups/amxmodx/tmp3/phpXioGQs.sma(16) : warning 217: loose indentation
/home/groups/amxmodx/tmp3/phpXioGQs.sma(18) : warning 217: loose indentation

Also, thanks, but ML isn't a requeriment for post new plugins, only the english is a must. And for this reason I added the three lines to edit the text.

BOYSplayCS 02-26-2009 11:02

Re: Buy Zoom
 
Quote:

Originally Posted by fezh (Post 769471)
Yea, but my plugin doesn't get warnings on compilation..

Luls, owned.

Starsailor 02-26-2009 11:17

Re: Buy Zoom
 
i have indented the code for you

PHP Code:

#include <amxmodx>
#include <cstrike>

#define ZOOMMSG "You have bought Zoom!"
#define REMMSG "Your Zoom has been removed."
#define DONTZOOM "You don't have enough money to buy Zoom."

new zoom_cost 
new bool:g_hasZoom[33]

public 
plugin_init() 
{
    
register_plugin("Buy Zoom""1.0""fezh")
    
register_event("ResetHUD","new_round","b")
    
register_event("DeathMsg""user_dead""a")
    
register_clcmd("say /zoom""set_zoom")
    
register_clcmd("say_team /zoom""set_zoom")
    
register_clcmd("say /remove""remove_zoom")
    
register_clcmd("say_team /remove""remove_zoom")
    
zoom_cost register_cvar("amxx_zoom_cost""500")
}

public 
client_connect(id)
{
    
g_hasZoom[id] = false
}

public 
client_disconnect(id)
{
    
g_hasZoom[id] = false
}

public 
user_dead(id)
{
    
g_hasZoom[id] = false
}

public 
new_round(id)
{
    
g_hasZoom[id] = false
}

public 
remove_zoom(id)
{
    
g_hasZoom[id] = false
    cs_set_user_zoom
(idCS_RESET_ZOOM0)
    
client_print(idprint_chat"[AMXX] %s"REMMSG)
    
    return 
PLUGIN_HANDLED
}

public 
set_zoom(id)
{
    if (
cs_get_user_money(id) < get_pcvar_num(zoom_cost))
    {
        
client_print(idprint_chat"[AMXX] %s"DONTZOOM)
        
        return 
PLUGIN_HANDLED
    
}
    
    
g_hasZoom[id] = true
    cs_set_user_money
(idcs_get_user_money(id) - get_pcvar_num(zoom_cost), 1)
    
cs_set_user_zoom(idCS_SET_AUGSG552_ZOOM0)
    
client_print(idprint_chat"[AMXX] %s"ZOOMMSG)
    
    return 
PLUGIN_HANDLED


and gHasZoom isnt used

you have to put

PHP Code:

if(!g_hasZoom[id]) {
    
g_hasZoom[id] = true
    cs_set_user_money
(idcs_get_user_money(id) - get_pcvar_num(zoom_cost), 1)
    
cs_set_user_zoom(idCS_SET_AUGSG552_ZOOM0)
    
client_print(idprint_chat"[AMXX] %s"ZOOMMSG)
}
else
    
client_print(idprint_chat"[AMXX] You already have a zoom"


Arkshine 02-26-2009 12:05

Re: Buy Zoom
 
Some suggestions :

- You should indent your code properly ; either use tab or space but not both.
- You should provide a command to toggle zoom so it can be bindable and used more easily.
- set_zoom() ; cache the value from cs_get_user_money and get_pcvar_num.
- g_hasZoom is not used at all.
- You could keep the zoom until you die, as feature.
- Using ML system ?
- Don't use ResetHud as new round ; see this tuto : http://forums.alliedmods.net/showthread.php?t=42159

Quote:

Well, this is my first "real" plugin
Read that : http://forums.alliedmods.net/showthread.php?t=11201

fezh 03-02-2009 15:39

Re: Buy Zoom
 
Plugin updated to version 1.2


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

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