Raised This Month: $ Target: $400
 0% 

[ Solved ] help with code optimizing


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 07-25-2008 , 10:26   [ Solved ] help with code optimizing
Reply With Quote #1

someone can optimize my code pls ? +karma
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <fun>
#include <colorchat>

/* Night Club
 *     Original from "Advanced Roll The Dice"
 * 
 * (c) Copyright 2008 xPaw.
 * 
 *  Credits:
 * 
 *    Striker        - his "Advanced Roll The Dice"
 *    OpenMind    - Helping ;)
 */

new HasPrize[33][2];
new 
sprBflare;
new 
sprRflare;
new 
sprGflare;
new 
sprTflare;
new 
sprOflare;
new 
sprPflare;
new 
sprYflare;
new 
bool:Nightclub;

public 
plugin_init()
{
    
register_plugin("Night Club","1.6","xPaw");

    
register_clcmd("say /club""nightclub");
    
register_clcmd("say club""nightclub");
    
register_clcmd("say_team /club""nightclub");
    
register_clcmd("say_team club""nightclub");
    
register_clcmd("club""nightclub");

    
register_cvar("sv_club_time""10");
    
register_cvar("sv_club_flare_count""12");
}

public 
plugin_precache()
{
    
sprBflare precache_model("sprites/fireworks/bflare.spr");
    
sprRflare precache_model("sprites/fireworks/rflare.spr");
    
sprGflare precache_model("sprites/fireworks/gflare.spr");
    
sprTflare precache_model("sprites/fireworks/tflare.spr");
    
sprOflare precache_model("sprites/fireworks/oflare.spr");
    
sprPflare precache_model("sprites/fireworks/pflare.spr");
    
sprYflare precache_model("sprites/fireworks/yflare.spr");

    
precache_sound("misc/xPaw/benny1.wav");
    
precache_sound("misc/xPaw/candyshop.mp3");
    
precache_sound("misc/xPaw/crazy.mp3");
    
precache_sound("misc/xPaw/fighter.mp3");
    
precache_sound("misc/xPaw/poppin.mp3");
    
precache_sound("misc/xPaw/vodka.mp3");
    
precache_sound("misc/xPaw/coco.mp3");
    
precache_sound("misc/xPaw/makeit.mp3");
    
    return 
PLUGIN_CONTINUE;
}

public 
nightclub(id)
{
    if(!
is_user_alive(id))
    {
         
ColorChat(idRED"^x01**^x04 Dead people dont go to^x03 Nightclub!")
    }
    if(
Nightclub)
    {
        
ColorChat(idRED"^x01**^x04 Now you cant go to^x03 Nightclub,^x04 try later!"
    }
    else
    {

        new 
rand random_num(1,8);
        new 
User[32], tid[2];
        
get_user_name(id,User,32);
        
HasPrize[id][1] = get_cvar_num("sv_club_time");
        
Nightclub true;
    
        
tid[0] = id;
        
tid[1] = 1;
        
set_task(0.1,"single_knife",0,tid,2,"a",((HasPrize[id][1]+2)*10)-10);
        
set_task(15.0"nightclub_off");

            if(
rand == 1) {
                
ColorChat(0BLUE"^x01**^x03 %s^x04 is dancing at the^x03 NightClub,^x04 here is^x01 60-x Party^x01 :)",User)
                
client_cmd(0,"spk misc/xPaw/benny1.wav");
            }
            if(
rand == 2) {
                
ColorChat(0BLUE"^x01**^x03 %s^x04 is dancing at the^x03 NightClub,^x04 here is^x01 50cent!",User)
                
client_cmd(0,"mp3 play sound/misc/xPaw/candyshop.mp3");
            }
            if(
rand == 3) {
                
ColorChat(0BLUE"^x01**^x03 %s^x04 is dancing at the^x03 NightClub,^x04 here is^x01 CrazyGirl!",User)
                
client_cmd(0,"mp3 play sound/misc/xPaw/crazy.mp3");
            }
            if(
rand == 4) {
                
ColorChat(0BLUE"^x01**^x03 %s^x04 is dancing at the^x03 NightClub,^x04 here is^x01 DJ Fighter!",User)
                
client_cmd(0,"mp3 play sound/misc/xPaw/fighter.mp3");
            }
            if(
rand == 5) {
                
ColorChat(0BLUE"^x01**^x03 %s^x04 is dancing at the^x03 NightClub,^x04 here is^x01 DJ DarkSide ;D",User)
                
client_cmd(0,"mp3 play sound/misc/xPaw/poppin.mp3");
            }
            if(
rand == 6) {
                
ColorChat(0BLUE"^x01**^x03 %s^x04 is dancing at the^x03 NightClub,^x04 here is^x01 MC Russ!",User)
                
client_cmd(0,"mp3 play sound/misc/xPaw/vodka.mp3");
            }
            if(
rand == 7) {
                
ColorChat(0BLUE"^x01**^x03 %s^x04 is dancing at the^x03 NightClub,^x04 here is^x01 Mp3 :/",User)
                
client_cmd(0,"mp3 play sound/misc/xPaw/makeit.mp3");
            }
            if(
rand == 8) {
                
ColorChat(0BLUE"^x01**^x03 %s^x04 is dancing at the^x03 NightClub,^x04 here is^x01 DJ CoCo :D",User)
                
client_cmd(0,"mp3 play sound/misc/xPaw/coco.mp3");
            }
    }
}

public 
nightclub_off(id) {
    
ColorChat(0RED"^x01**^x04 Now^x03 Nightclub^x04 is open for ^x01guests!")

    
Nightclub false;
    
set_user_rendering(id)
}

public 
client_disconnect() {
   
Nightclub false;
}

public 
single_knife(id[])
{
        new 
r,g,b
        r 
random_num(0,255);
        
random_num(0,255);
        
random_num(0,255);

        new 
color random_num(0,255);
        new 
width random_num(400,1000);

        new 
korigin[3];
        
get_user_origin(id[0],korigin)

        
set_user_rendering(id[0],kRenderFxGlowShell,r,g,b,kRenderTransAlpha,255)

            
message_begin(MSG_BROADCAST,SVC_TEMPENTITY);
            
write_byte(15);                        // TE_SPRITETRAIL
            
write_coord(korigin[0]);            // coord, coord, coord (start)
            
write_coord(korigin[1]);
            
write_coord(korigin[2]-20);
            
write_coord(korigin[0]);            // coord, coord, coord (end)
            
write_coord(korigin[1]);
            
write_coord(korigin[2]+20);
            
            if ((
128) && (127) && (127))
                
write_short(sprRflare);
            
            else if ((
127) && (128) && (127))
                
write_short(sprGflare);
            
            else if ((
127) && (127) && (128))
                
write_short(sprBflare);
                
            else if ((
127) && (128) && (128))
                
write_short(sprTflare);
                
            else if ((
128) && (127) && (200) && (100))
                
write_short(sprPflare);
                
            else if ((
128) && (128) && (127))
                
write_short(sprYflare);
                
            else if ((
128) && (100) && (200) && (127))
                
write_short(sprOflare);
            else
                
write_short(sprBflare);
            
            
write_byte(get_cvar_num("sv_club_flare_count"));    // byte (count)
            
write_byte(10);                        // byte (life in 0.1's)
            
write_byte(10);                        // byte (scale in 0.1's)
            
write_byte(random_num(40,100));        // byte (velocity along vector in 10's)
            
write_byte(40);                        // byte (randomness of velocity in 10's)
            
message_end(); 

            
message_begin(MSG_BROADCAST,SVC_TEMPENTITY);
            
write_byte(27);
            
write_coord(korigin[0]);    // coord, coord, coord (start)
            
write_coord(korigin[1]);
            
write_coord(korigin[2]);
            
write_byte(30);            // byte (radius in 10's) 
            
write_byte(r);            // byte byte byte (color)
            
write_byte(g);
            
write_byte(b);
            
write_byte(70);            // byte (life in 10's)
            
write_byte(11);            // byte (decay rate in 10's)
            
message_end();

            
message_begin(MSG_BROADCAST,SVC_TEMPENTITY);
            
write_byte(122);         // very similar to lavasplash.
            
write_coord(korigin[0]);    // coord, coord, coord (start)
            
write_coord(korigin[1]);
            
write_coord(korigin[2]);
            
write_short (width);
            
write_byte (color);         // (particle color)
            
write_byte (40);         // (duration * 10) (will be randomized a bit)
            
message_end();

            
message_begin(MSG_BROADCAST,SVC_TEMPENTITY);
            
write_byte(14);
            
write_coord(korigin[0]);
            
write_coord(korigin[1]);
            
write_coord(korigin[2]-100);
            
write_byte(3500);         // radius
            
write_byte(80);
            
write_byte(20);
            
message_end();


Last edited by xPaw; 08-26-2008 at 09:05.
xPaw 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 05:28.


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