Raised This Month: $32 Target: $400
 8% 

API Scripting Help [TUT] ZP 5.0 Admin Only class


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Sp@jk
Member
Join Date: May 2010
Location: Serbia
Old 08-23-2011 , 05:35   [TUT] ZP 5.0 Admin Only class
Reply With Quote #1

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

Last edited by Sp@jk; 08-23-2011 at 11:29.
Sp@jk is offline
bboygrun
CHOMP
Join Date: May 2010
Location: France
Old 08-23-2011 , 07:56   Re: [TUT] ZP 5.0 Admin Only class
Reply With Quote #2

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 



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

__________________
bboygrun is offline
abdul-rehman
Veteran Member
Join Date: Jan 2010
Location: Khi, Pakistan
Old 08-23-2011 , 09:25   Re: [TUT] ZP 5.0 Admin Only class
Reply With Quote #3

This shows how powerful ZP 5.0's API is
__________________

My Plugins For ZP

Inactive due to College and Studies
abdul-rehman is offline
Send a message via Yahoo to abdul-rehman Send a message via Skype™ to abdul-rehman
Sp@jk
Member
Join Date: May 2010
Location: Serbia
Old 08-23-2011 , 10:44   Re: [TUT] ZP 5.0 Admin Only class
Reply With Quote #4

Quote:
Originally Posted by abdul-rehman View Post
This shows how powerful ZP 5.0's API is
yes, now I can sell classes to players and earn money
Sp@jk is offline
abdul-rehman
Veteran Member
Join Date: Jan 2010
Location: Khi, Pakistan
Old 08-23-2011 , 10:59   Re: [TUT] ZP 5.0 Admin Only class
Reply With Quote #5

Quote:
Originally Posted by Sp@jk View Post
yes, now I can sell classes to players and earn money
Then we should start selling ZP 5.0 stable version
__________________

My Plugins For ZP

Inactive due to College and Studies
abdul-rehman is offline
Send a message via Yahoo to abdul-rehman Send a message via Skype™ to abdul-rehman
Sp@jk
Member
Join Date: May 2010
Location: Serbia
Old 08-23-2011 , 11:28   Re: [TUT] ZP 5.0 Admin Only class
Reply With Quote #6

Quote:
Originally Posted by abdul-rehman View Post
Then we should start selling ZP 5.0 stable version
haha
Sp@jk is offline
bartek93tbg
Member
Join Date: Apr 2011
Location: Poland
Old 08-23-2011 , 12:03   Re: [TUT] ZP 5.0 Admin Only class
Reply With Quote #7

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)
        }
}
bartek93tbg is offline
klatro
Senior Member
Join Date: Oct 2009
Location: The world and at home
Old 08-23-2011 , 12:23   Re: [TUT] ZP 5.0 Admin Only class
Reply With Quote #8

Quote:
Originally Posted by bartek93tbg View Post
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
klatro is offline
Sp@jk
Member
Join Date: May 2010
Location: Serbia
Old 08-23-2011 , 13:48   Re: [TUT] ZP 5.0 Admin Only class
Reply With Quote #9

Quote:
Originally Posted by bartek93tbg View Post
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
Sp@jk is offline
bartek93tbg
Member
Join Date: Apr 2011
Location: Poland
Old 08-23-2011 , 14:59   Re: [TUT] ZP 5.0 Admin Only class
Reply With Quote #10

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.

Last edited by bartek93tbg; 08-23-2011 at 15:03.
bartek93tbg is offline
Reply



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 02:41.


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