AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Zombie Plague Mod (https://forums.alliedmods.net/forumdisplay.php?f=126)
-   -   Subplugin Submission [ZP] Weapon Licenses (natives) [1.0.3] (https://forums.alliedmods.net/showthread.php?t=196393)

SergiCruz 09-20-2012 07:22

[ZP] Weapon Licenses (natives) [1.0.3]
 
3 Attachment(s)
* This plugin is a bunch of extra items; all of them are licenses.
* Has is own INC with its natives, in order to make it possible to need a license to buy a extra weapons.
* There are 5 licenses (Heavy, Sub, Rifle, Pistols and Shotguns) Edit: 6 licenses; added golden
* You need to edit your extra items (or custom menus) to make them compatible with licenses.
* Once you have purchased one license, you will have them until the end of the map.

Main plugin (OBLIGATORY): zp_licenses
Inc (OBLIGATORY): licenses

Simple example of how to do a extra item with licenses:

PHP Code:

#include <amxmodx>
#include <zombieplague>
#include <cstrike>
#include <fun>
#include <licenses> // This include contains the licenses' natives

#define PLUGIN "This is just an example"
#define VERSION "1.0"
#define AUTHOR "Sergicruz"

// From here nothing important...

new g_mac10

public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
g_mac10 zp_register_extra_item("Mac10 + 200B"7ZP_TEAM_HUMAN)
}

// YOU HAVE TO DO THE MODIFICATIONS HERE
public zp_extra_item_selected(iditemid)
{
    if(
itemid == g_mac10)
    {
        if(!
zp_has_user_subs_license(id)) // If user hasn't subs license...
        
{
            
client_print(idprint_chat"You need subs license"// we tell him that he needs it
            
zp_set_user_ammo_packs(id, (zp_get_user_ammo_packs(id) + 7)) //and we give back his ammopacks
        
}
        else{ 
//in other case...
        
give_item(id"weapon_mac10"//we make him happy
        
cs_set_user_bpammo(idCSW_MAC10200// very happy
    
}
    }



Credits:
* Rak: for explaining me how to use natives
* Mercylezz: for his awesome zombie plague
* Ciio: For explaining how to do a simple extra item
* H.Red.Zone: For his help improving the code
* Gogicaa: For helping me with spelling (:D)
Cooming soon...
* Golden license (or similar) Done
* Cvars for enable/disable licenses
* Natives for detect wether are licenses enabled or disabled
* Natives for giving licenses Done
CHANGELOG:
* First release 20/9/12 13:22
* As H.Red.Zone suggested, added library 20/9/2012 17:45
* As H.Red.Zone suggested, added DEFINE for license cost 20/9/2012 18:03
*
Added golden license (give all licenses) 11/2/2013 20:51
* Added natives for giving licenses 11/2/2013 20:51

H.RED.ZONE 09-20-2012 10:22

Re: [ZP] Weapon Licenses (natives) [1.0.0]
 
Nice, Great Idea.

Let me show you how you can improve your code.

Natives.
zp_has_user_silver_license
zp_has_user_golden_license

Code.
Spoiler


Improvements i did and you can copy and see.
* Useing Bits.
* Removed Amxmisc.
* Added define for setting cost.
* I wrote so you can see everything

It was fast i think i didn't made any mistakes.


Suggestions For Your Code:
* Use Bits.
* Look At The Code I Gave You.
* Add (Admin Licence) (Premium Licence) Not Only ShotGun And So On...
* You Can Add (Golden Licence || Silver Licence)
* Show People How They Can Set Checks.
(If I get Any More Suggestions I Will Tell You X)

And Again Nice Job And Great Idea.

EDIT: You Forgot to register the lybrary.
Code:

    // Register Lybrary.
    register_library( "licenses" )


gogicaa 09-20-2012 10:26

Re: [ZP] Weapon Licenses (natives) [1.0.0]
 
Wow, great idea Sergi :)
Unfortunately, i don't have time to test it...

SergiCruz 09-20-2012 11:15

Re: [ZP] Weapon Licenses (natives) [1.0.0]
 
@H.Red.Zone: I didn't understand very well your plugin, i'm not so good at scripting. Anyway, i'll try to learn some things from your code so... thanks very much!! For the moment, Lybrary added and amxmisc deleted :)
@gogicaa: Thanks :) I hope to have the time to improve it.

gogicaa 09-20-2012 12:11

Re: [ZP] Weapon Licenses (natives) [1.0.2]
 
Oh, and it not CHANGELOG, not CHANGELOT :)

H.RED.ZONE 09-20-2012 12:17

Re: [ZP] Weapon Licenses (natives) [1.0.0]
 
Quote:

Originally Posted by SergiCruz (Post 1802808)
@H.Red.Zone: I didn't understand very well your plugin, i'm not so good at scripting. Anyway, i'll try to learn some things from your code so... thanks very much!! For the moment, Lybrary added and amxmisc deleted :)

If you need explanation feel free to PM me.

SergiCruz 09-20-2012 12:19

Re: [ZP] Weapon Licenses (natives) [1.0.2]
 
Quote:

Oh, and it not CHANGELOG, not CHANGELOT
hahaha thanks dude
Quote:

If you need explanation feel free to PM me.
Thanks!! i think it's better with bits, but i don't know how to use them. I will read something about them and then, i'll ask you :)

SergiCruz 02-11-2013 15:00

Re: [ZP] Weapon Licenses (natives) [1.0.3]
 
(Sorry for double-posting)
Updated [11/2/2013]. Changes in changelog. It needs a re-download.


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

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