AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Zombie Plague Mod (https://forums.alliedmods.net/forumdisplay.php?f=126)
-   -   API Scripting Help [TUT] ZP 5.0 Admin Only class (https://forums.alliedmods.net/showthread.php?t=165450)

Sp@jk 08-23-2011 05:35

[TUT] ZP 5.0 Admin Only class
 
Hi, I am going to show you how to make a admin only class in ZP 5.0

First we make a simple class:
PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <zp50_class_zombie>

public plugin_precache()
{
    
register_plugin("Admin only class","1.0","Sp@jk")
    
zp_class_zombie_register("Admin Zombie","Only admins can use!",5000,300.0,0.5)


Then we add a class id
PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <zp50_class_zombie>

new class_id

public plugin_precache()
{
    
register_plugin("Admin only class","1.0","Sp@jk")
    
class_id zp_class_zombie_register("Admin Zombie","Only admins can use!",5000,300.0,0.5)


Now we add zp_fw_class_zombie_select_pre forward and check if user is admin
PHP Code:


#include <amxmodx>
#include <amxmisc>
#include <zp50_class_zombie>

new class_id

public plugin_precache()
{
    
register_plugin("Admin only class","1.0","Sp@jk")
    
class_id zp_class_zombie_register("Admin Zombie","Only admins can use!",5000,300.0,0.5)
}

public 
zp_fw_class_zombie_select_pre(id,cid)
{
    if(
cid==class_id)
    {
        if(!
is_user_admin(id))
            return 
ZP_CLASS_NOT_AVAILABLE
    
}
    return 
ZP_CLASS_AVAILABLE


And now we have a class than only admin can use :)

bboygrun 08-23-2011 07:56

Re: [TUT] ZP 5.0 Admin Only class
 
PHP Code:

#include <amxmodx> 
#include <amxmisc> 
#include <zp50_class_zombie> 

new class_id 

public plugin_precache() 

    
register_plugin("Admin only class","1.0","Sp@jk"
    
class_id zp_class_zombie_register("Admin Zombie","Only admins can use!",5000,300.0,0.5


public 
zp_fw_class_zombie_select_pre(id,cid

    if(
cid==class_id
    { 
        if(!
is_user_admin(id)) 
            return 
ZP_CLASS_NOT_AVAILABLE 
        
else 
            return 
ZP_CLASS_AVAILABLE 
    

    return 
ZP_CLASS_AVAILABLE 


:arrow:

PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <zp50_class_zombie>

new class_id

public plugin_precache()
{
    
register_plugin("Admin only class","1.0","Sp@jk")
    
class_id zp_class_zombie_register("Admin Zombie","Only admins can use!",5000,300.0,0.5)
}

public 
zp_fw_class_zombie_select_pre(id,cid)
{
    if( 
cid==class_id )
    {
        if(!
is_user_admin(id))
            return 
ZP_CLASS_NOT_AVAILABLE
    
}
    return 
ZP_CLASS_AVAILABLE



abdul-rehman 08-23-2011 09:25

Re: [TUT] ZP 5.0 Admin Only class
 
This shows how powerful ZP 5.0's API is :lol:

Sp@jk 08-23-2011 10:44

Re: [TUT] ZP 5.0 Admin Only class
 
Quote:

Originally Posted by abdul-rehman (Post 1539238)
This shows how powerful ZP 5.0's API is :lol:

yes, now I can sell classes to players and earn money :D

abdul-rehman 08-23-2011 10:59

Re: [TUT] ZP 5.0 Admin Only class
 
Quote:

Originally Posted by Sp@jk (Post 1539285)
yes, now I can sell classes to players and earn money :D

Then we should start selling ZP 5.0 stable version :lol:

Sp@jk 08-23-2011 11:28

Re: [TUT] ZP 5.0 Admin Only class
 
Quote:

Originally Posted by abdul-rehman (Post 1539294)
Then we should start selling ZP 5.0 stable version :lol:

haha :D

bartek93tbg 08-23-2011 12:03

Re: [TUT] ZP 5.0 Admin Only class
 
It is possible to make admin class even in ZP 4.3
Just use forward zp_user_infected_pre
example:

Code:

public zp_user_infected_pre(id)
{
        if((zp_get_user_next_class(id) == your_class_id) && !(get_user_flags(id) & ADMIN_BAN))
        {
            client_print(id, print_chat, "[ZP] Only admins can use this class!")
            zp_set_user_zombie_class(id, 0)
        }
}


klatro 08-23-2011 12:23

Re: [TUT] ZP 5.0 Admin Only class
 
Quote:

Originally Posted by bartek93tbg (Post 1539338)
It is possible to make admin class even in ZP 4.3
Just use forward zp_user_infected_pre
example:

Code:

public zp_user_infected_pre(id)
{
        if((zp_get_user_next_class(id) == your_class_id) && !(get_user_flags(id) & ADMIN_BAN))
        {
            client_print(id, print_chat, "[ZP] Only admins can use this class!")
            zp_set_user_zombie_class(id, 0)
        }
}


Really? Huh.. xd

Sp@jk 08-23-2011 13:48

Re: [TUT] ZP 5.0 Admin Only class
 
Quote:

Originally Posted by bartek93tbg (Post 1539338)
It is possible to make admin class even in ZP 4.3
Just use forward zp_user_infected_pre
example:

Code:

public zp_user_infected_pre(id)
{
        if((zp_get_user_next_class(id) == your_class_id) && !(get_user_flags(id) & ADMIN_BAN))
        {
            client_print(id, print_chat, "[ZP] Only admins can use this class!")
            zp_set_user_zombie_class(id, 0)
        }
}


You still can select that class, this just prevent user to spawn with that class

bartek93tbg 08-23-2011 14:59

Re: [TUT] ZP 5.0 Admin Only class
 
Sure, but ZP 5.0 is still in beta, so no one will use it until it is stable. If someone want admin class now, he might use this solution. It works in practice very good.


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

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