Raised This Month: $ Target: $400
 0% 

Can someone break this down ?


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Sllipindk
Junior Member
Join Date: Jul 2007
Old 07-23-2007 , 19:11   Can someone break this down ?
Reply With Quote #1

Hello, I am understanding the very basics of PAWN coding, Now for me to get better and into further depth of the coding world I will need to look at other peoples plugins and analyze and examine it, Especially the plugins that relate to the type of plugins that I will be making.

If anyone will be so kind of enough to break down the, "Pepper Spray" plugin by James J Kelly Jr. which is used as a Item in Harbu's RP mod.

Code:
#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <engine_stocks>
#include <fun>
#include <harbu>

#define FFADE_STAYOUT 0x0004

#define SPRAY_DISTANCE 100

#define SPRAY_SOUND "player/sprayer.wav"

new playerTask[32];

public plugin_init()
{

    register_plugin("Pepper Spray","0.0.0.0","James J Kelly Jr");

    register_srvcmd("item_pepperspray","item_pepperspray");    

}

public client_connect(id)
{

    playerTask[id] = 0;

}

public client_disconnect(id)
{

    playerTask[id] = 0;

}

public plugin_precache()
{

    precache_sound(SPRAY_SOUND);

}

public item_pepperspray()
{

    new strArguments[2][32];
    
    read_argv(1,strArguments[0],31);
    read_argv(2,strArguments[1],31);
    
    if( equali(strArguments[0],"") ) return PLUGIN_HANDLED;
    if( equali(strArguments[1],"") ) return PLUGIN_HANDLED;
    
    new numArguments[2];
    
    numArguments[0] = str_to_num(strArguments[0]);
    numArguments[1] = str_to_num(strArguments[1]);
    
    if( !(is_user_connected(numArguments[0]) && is_user_alive(numArguments[0])) ) return PLUGIN_HANDLED;
    if( !(is_user_connected(numArguments[1]) && is_user_alive(numArguments[1])) ) return PLUGIN_HANDLED;
    
    /*
    new target, body;
    
    get_user_aiming(numArguments[0],target,body,SPRAY_DISTANCE);
    */
    
    new target = numArguments[1];
    
    if( !(is_user_connected(target) && is_user_alive(target)) )
    {
    
        client_print(numArguments[0],print_chat,"[PepperSprayMod] You need to be looking at someone to spray!^n");
        
        return PLUGIN_HANDLED;
    
    }
    
    if( playerTask[target] ) remove_task(playerTask[target],0);
    
    playerTask[target] = random_num(1,1000000);
    
    message_begin(MSG_ONE,get_user_msgid("ScreenFade"),{0,0,0},target);
    write_short(1<<15);
    write_short(1<<12);
    write_short(FFADE_STAYOUT);
    write_byte(177);
    write_byte(177);
    write_byte(20);
    write_byte(250);
    message_end();
    
    new params[2];
        
    params[0] = target;
    params[1] = playerTask[target]
    set_task(10.0,"task_undo",playerTask[target],params,2);
    
    new name[2][32];
    
    get_user_mask(numArguments[0],name[0],31);
    get_user_mask(target,name[1],31);
    
    client_print(numArguments[0],print_chat,"[PepperSprayMod] You have sprayed %s in the eyes!^n",name[1]);
    client_print(target,print_chat,"[PepperSprayMod] %s has sprayed you in the eyes!^n",name[0]);
    
    emit_sound(numArguments[0],CHAN_ITEM,SPRAY_SOUND,1.0,ATTN_NORM,0,PITCH_NORM);
    
    return PLUGIN_HANDLED;

}

public task_undo(params[],id)
{

    new player = params[0];
    
    if( !(is_user_connected(player) && is_user_alive(player) && playerTask[player] == params[1]) ) return PLUGIN_HANDLED;

    message_begin(MSG_ONE,get_user_msgid("ScreenFade"),{0,0,0},player);
    write_short(1<<15);
    write_short(1<<12);
    write_short(1<<12);
    write_byte(177);
    write_byte(177);
    write_byte(20);
    write_byte(250);
    message_end();

    return PLUGIN_HANDLED;

}
Thanks you very much.

-Sllipindk
Sllipindk is offline
 



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 21:25.


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