Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <amxmodx>
- #include <amxmisc>
- #include <cstrike>
- #include <engine>
- #include <fun>
- #include <hamsandwich>
- #include <nvault>
- #define PLUGIN "Knife Shop"
- #define VERSION "3.0"
- #define AUTHOR "Dr.Small a.k.a DukMeN"
- #define iPrefix "[Knife Shop]"
- enum Color
- {
- NORMAL = 1,
- GREEN,
- TEAM_COLOR,
- GREY,
- RED,
- BLUE,
- }
- new TeamName[][] =
- {
- "",
- "TERRORIST",
- "CT",
- "SPECTATOR"
- }
- // Pcvars
- new hecost;
- new flashcost;
- new gravitycost;
- new healthcost;
- new armorcost;
- new speedcost;
- new godmodecost;
- new silentcost;
- new awpcost;
- new deaglecost;
- new noclipcost;
- new camocost;
- new time_gravity;
- new time_speed;
- new time_godmode;
- new time_silent;
- new time_noclip;
- new time_camo;
- new health_ammount;
- new armor_ammount;
- new awp_ammo;
- new deagle_ammo;
- new hud_color;
- new HasHe[33];
- new HasFlash[33];
- new HasGravity[33];
- new HasHealth[33];
- new HasArmor[33];
- new HasSpeed[33];
- new HasGodmode[33];
- new HasSilent[33];
- new HasAwp[33];
- new HasDeagle[33];
- new HasNoclip[33];
- new HasCamo[33];
- new iSpeed[33];
- new iCamoOldModel[33][32];
- new const PlayerModels[ ][ ] =
- {
- "arctic",
- "leet",
- "guerilla",
- "terror",
- "gign",
- "urban",
- "sas",
- "gsg9"
- }
- new iPlayerPoints[ 33 ];
- new vault, sync;
- public plugin_init()
- {
- register_plugin(PLUGIN, VERSION, AUTHOR);
- register_event( "CurWeapon", "EventCurWeapon", "be", "1=1" );
- register_event( "DeathMsg", "EventDeath", "a" );
- register_logevent( "logevRoundStart", 2, "1=Round_Start" );
- register_concmd( "knifeshop_give_points", "GivePoints", ADMIN_RCON, "<name, #userid, authid> <points>" );
- register_concmd( "knifeshop_remove_points", "RemovePoints", ADMIN_RCON, "<name, #userid, authid> <points>" );
- hecost = register_cvar("knifeshop_he_cost", "2");
- flashcost = register_cvar("knifeshop_flash_cost", "1");
- gravitycost = register_cvar("knifeshop_gravity_cost", "3");
- healthcost = register_cvar("knifeshop_health_cost", "6");
- armorcost = register_cvar("knifeshop_armor_cost", "4");
- speedcost = register_cvar("knifeshop_speed_cost", "4");
- godmodecost = register_cvar("knifeshop_godmode_cost", "7");
- silentcost = register_cvar("knifeshop_silent_cost", "3");
- awpcost = register_cvar("knifeshop_awp_cost", "8");
- deaglecost = register_cvar("knifeshop_deagle_cost", "7");
- noclipcost = register_cvar("knifeshop_noclip_cost", "13");
- camocost = register_cvar("knifeshop_camo_cost", "5");
- time_gravity = register_cvar("knifeshop_gravity_time", "10");
- time_speed = register_cvar("knifeshop_speed_time", "20");
- time_godmode = register_cvar("knifeshop_godmode_time", "12");
- time_silent = register_cvar("knifeshop_silent_time", "30");
- time_noclip = register_cvar("knifeshop_noclip_time", "7");
- time_camo = register_cvar("knifeshop_camo_time", "15");
- health_ammount = register_cvar("knifeshop_ammount_hp", "120");
- armor_ammount = register_cvar("knifeshop_ammount_armor", "60");
- awp_ammo = register_cvar("knifeshop_awp_ammo", "1");
- deagle_ammo = register_cvar("knifeshop_deagle_ammo", "2");
- hud_color = register_cvar("knifeshop_hud_color", "255 255 0" );
- register_clcmd("say /knifeshop", "MainMenu");
- register_clcmd("say /shop", "MainMenu");
- register_clcmd("say knifeshop", "MainMenu");
- register_clcmd("say shop", "MainMenu");
- vault = nvault_open( "KnifeShop_v[2.9]" );
- sync = CreateHudSyncObj( );
- new ent = create_entity( "info_target" );
- entity_set_string( ent, EV_SZ_classname, "task_entity" );
- register_think( "task_entity", "CmdShowPoints" );
- entity_set_float( ent, EV_FL_nextthink, get_gametime( ) + 1.0 );
- set_task(400.0, "Advert", _,_,_, "b");
- }
- public GivePoints( id, level, cid )
- {
- if( !cmd_access( id, level, cid, 3) ) return PLUGIN_HANDLED;
- new arg[35];
- read_argv(1, arg, sizeof(arg) - 1);
- new target = cmd_target( id, arg, CMDTARGET_NO_BOTS );
- if( !target ) return PLUGIN_HANDLED;
- read_argv(2, arg, sizeof(arg) - 1);
- new points = str_to_num(arg);
- if( points <= 0 ) return PLUGIN_HANDLED;
- iPlayerPoints[ target ] += points;
- SavePoints( target );
- new name1[ 33 ], name2[ 33 ]
- get_user_name( id, name1, charsmax( name1 ) );
- get_user_name( target, name2, charsmax( name2 ) );
- ColorChat( 0, GREEN, "%s^1 ADMIN:^3 %s^1 give^4 %d^1 point%s to^3 %s.", iPrefix, name1, points, points > 1 ? "s" : "", name2 );
- return PLUGIN_HANDLED;
- }
- public RemovePoints( id, level, cid )
- {
- if( !cmd_access( id, level, cid, 3) ) return PLUGIN_HANDLED;
- new arg[35];
- read_argv(1, arg, sizeof(arg) - 1);
- new target = cmd_target( id, arg, CMDTARGET_NO_BOTS );
- if( !target ) return PLUGIN_HANDLED;
- read_argv(2, arg, sizeof(arg) - 1);
- new points = str_to_num(arg);
- if( points <= 0 ) return PLUGIN_HANDLED;
- iPlayerPoints[ target ] -= points;
- SavePoints( target );
- new name1[ 33 ], name2[ 33 ]
- get_user_name( id, name1, charsmax( name1 ) );
- get_user_name( target, name2, charsmax( name2 ) );
- ColorChat( 0, GREEN, "%s^1 ADMIN:^3 %s^1 removed^4 %d^1 point%s from^3 %s.", iPrefix, name1, points, points > 1 ? "s" : "", name2 );
- return PLUGIN_HANDLED;
- }
- public EventDeath( )
- {
- new killer = read_data( 1 );
- new victim = read_data( 2 );
- if( is_user_connected( killer ) && victim != killer )
- {
- if( read_data( 3 ) )
- {
- iPlayerPoints[ killer ] += 2;
- }
- else
- {
- iPlayerPoints[ killer ]++;
- }
- SavePoints( killer );
- }
- }
- public CmdShowPoints( ent )
- {
- new iPlayers[ 32 ], iNum, id;
- get_players( iPlayers, iNum, "ch" );
- for( new i; i < iNum; i++ )
- {
- id = iPlayers[ i ];
- if( is_user_alive( id ) )
- {
- static szRed, szGreen, szBlue;
- HudColors( szRed, szGreen, szBlue );
- set_hudmessage( szRed, szGreen, szBlue, 0.01, 0.91, 0, 0.9, 0.9 );
- ShowSyncHudMsg( id, sync, "Health: %d | Armor: %d | Point%s: %d", get_user_health( id ), get_user_armor( id ), iPlayerPoints[ id ] == 1 ? "" : "s", iPlayerPoints[ id ] );
- }
- }
- entity_set_float( ent, EV_FL_nextthink, get_gametime( ) + 0.1 );
- }
- public logevRoundStart( )
- {
- new iPlayers[ 32 ], iNum, id;
- get_players( iPlayers, iNum, "ch" );
- for( new i; i < iNum; i++ )
- {
- id = iPlayers[ i ];
- if( !is_user_alive( id ) ) return PLUGIN_CONTINUE;
- set_user_footsteps( id, 0 );
- set_user_gravity( id, 1.0 );
- set_user_godmode( id, 0 );
- set_user_noclip( id, 0);
- remove_task( id );
- HasHe[id] = false;
- HasFlash[id] = false;
- HasGravity[id] = false;
- HasHealth[id] = false;
- HasArmor[id] = false;
- HasSpeed[id] = false;
- HasGodmode[id] = false;
- HasSilent[id] = false;
- HasAwp[id] = false;
- HasDeagle[id] = false;
- HasNoclip[id] = false;
- HasCamo[id] = false;
- iSpeed[id] = false;
- }
- return PLUGIN_CONTINUE;
- }
- public client_authorized( id )
- {
- LoadPoints( id );
- }
- public client_disconnect( id )
- {
- SavePoints( id );
- }
- public MainMenu(id)
- {
- if( !is_user_alive( id ) )
- {
- ColorChat( id, GREEN, "%s^1 Need to be^3 alive to^4 use the^1 shop!", iPrefix );
- return PLUGIN_HANDLED;
- }
- new szShop[64], szHe[33], szFlash[33], szGravity[33], szHealth[33], szArmor[33], szSpeed[33], szGodmode[33], szSilent[33], szAwp[33], szDeagle[33], szNoclip[33], szCamo[33];
- formatex(szShop, charsmax(szShop), "\y%s \wv\r%s \wPage\r", PLUGIN, VERSION);
- formatex(szHe, charsmax(szHe), "\wHE Grenade - \y%d Point%s", get_pcvar_num(hecost), get_pcvar_num(hecost) == 1 ? "" : "s" );
- formatex(szFlash, charsmax(szFlash), "\wFlashbang - \y%d Point%s", get_pcvar_num(flashcost), get_pcvar_num(flashcost) == 1 ? "" : "s" );
- formatex(szGravity, charsmax(szGravity), "\wGravity - \y%d Point%s", get_pcvar_num(gravitycost), get_pcvar_num(gravitycost) == 1 ? "" : "s" );
- formatex(szHealth, charsmax(szHealth), "\w%d Health - \y%d Point%s", get_pcvar_num(health_ammount), get_pcvar_num(healthcost), get_pcvar_num(healthcost) == 1 ? "" : "s" );
- formatex(szArmor, charsmax(szArmor), "\w%d Armor - \y%d Point%s", get_pcvar_num(armor_ammount), get_pcvar_num(armorcost), get_pcvar_num(armorcost) == 1 ? "" : "s" );
- formatex(szSpeed, charsmax(szSpeed), "\wMore Speed - \y%d Point%s", get_pcvar_num(speedcost), get_pcvar_num(speedcost) == 1 ? "" : "s" );
- formatex(szGodmode, charsmax(szGodmode), "\wGodmode - \y%d Point%s", get_pcvar_num(godmodecost), get_pcvar_num(godmodecost) == 1 ? "" : "s" );
- formatex(szSilent, charsmax(szSilent), "\wSilent Walk - \y%d Point%s", get_pcvar_num(silentcost), get_pcvar_num(silentcost) == 1 ? "" : "s" );
- formatex(szAwp, charsmax(szAwp), "\wAWP - \y%d Point%s", get_pcvar_num(awpcost), get_pcvar_num(awpcost) == 1 ? "" : "s" );
- formatex(szDeagle, charsmax(szDeagle), "\wDeagle - \y%d Point%s", get_pcvar_num(deaglecost), get_pcvar_num(deaglecost) == 1 ? "" : "s" );
- formatex(szNoclip, charsmax(szNoclip), "\wNoclip - \y%d Point%s", get_pcvar_num(noclipcost), get_pcvar_num(noclipcost) == 1 ? "" : "s" );
- formatex(szCamo, charsmax(szCamo), "\wCamouflage - \y%d Point%s", get_pcvar_num(camocost), get_pcvar_num(camocost) == 1 ? "" : "s" );
- new shop = menu_create(szShop, "knife_shop_handler");
- menu_additem(shop, szHe, "1", 0);
- menu_additem(shop, szFlash, "2", 0);
- menu_additem(shop, szGravity, "3", 0);
- menu_additem(shop, szHealth, "4", 0);
- menu_additem(shop, szArmor, "5", 0);
- menu_additem(shop, szSpeed, "6", 0);
- menu_additem(shop, szGodmode, "7", 0);
- menu_additem(shop, szSilent, "8", 0);
- menu_additem(shop, szAwp, "9", 0);
- menu_additem(shop, szDeagle, "10", 0);
- menu_additem(shop, szNoclip, "11", 0);
- menu_additem(shop, szCamo, "12", 0);
- menu_setprop(shop, MPROP_EXIT, MEXIT_ALL);
- menu_display(id, shop, 0);
- return PLUGIN_HANDLED;
- }
- public knife_shop_handler(id, shop, item)
- {
- if(item == MENU_EXIT)
- {
- menu_destroy(shop);
- return PLUGIN_HANDLED;
- }
- new data[6], iName[64], szName[33], iaccess, callback;
- menu_item_getinfo(shop, item, iaccess, data, 6, iName, 63, callback);
- get_user_name(id, szName, charsmax( szName ));
- switch(str_to_num(data))
- {
- case 1: // HE Grenade
- {
- if( iPlayerPoints[ id ] >= get_pcvar_num( hecost ) )
- {
- if( user_has_weapon( id, CSW_HEGRENADE ) ) return PLUGIN_HANDLED;
- give_item( id, "weapon_hegrenade" );
- iPlayerPoints[ id ] -= get_pcvar_num( hecost );
- HasHe[ id ] = true;
- ColorChat(0, TEAM_COLOR, "%s^x04 %s^x01 has bought^x03 HE Grenade^x01.", iPrefix, szName);
- }
- else NoPoints( id );
- }
- case 2: // Flashbang
- {
- if( iPlayerPoints[ id ] >= get_pcvar_num( flashcost ) )
- {
- give_item( id, "weapon_flashbang" );
- iPlayerPoints[ id ] -= get_pcvar_num( flashcost );
- HasFlash[ id ] = true;
- ColorChat(0, TEAM_COLOR, "%s^x04 %s^x01 has bought^x03 Flashbang^x01.", iPrefix, szName);
- }
- else NoPoints( id );
- }
- case 3: // Gravity
- {
- if( iPlayerPoints[ id ] >= get_pcvar_num( gravitycost ) )
- {
- set_user_gravity(id, 0.40)
- set_task(get_pcvar_float(time_gravity), "remove_gravity", id)
- iPlayerPoints[ id ] -= get_pcvar_num( gravitycost );
- HasGravity[ id ] = true;
- ColorChat(0, TEAM_COLOR, "%s^x04 %s^x01 bought^x03 Gravity^x01 from^x04 %d^x01 sek.", iPrefix, szName, get_pcvar_num(time_gravity));
- }
- else NoPoints( id );
- }
- case 4: // Health
- {
- if( iPlayerPoints[ id ] >= get_pcvar_num( healthcost ) )
- {
- set_user_health( id, get_user_health( id ) + get_pcvar_num(health_ammount) );
- iPlayerPoints[ id ] -= get_pcvar_num( healthcost );
- HasHealth[ id ] = true;
- }
- else NoPoints( id );
- }
- case 5: // Armor
- {
- if( iPlayerPoints[ id ] >= get_pcvar_num( armorcost ) )
- {
- set_user_armor( id, get_user_armor( id ) + get_pcvar_num(armor_ammount) );
- emit_sound(id, CHAN_ITEM, "items/ammopickup2.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM);
- iPlayerPoints[ id ] -= get_pcvar_num( armorcost );
- HasArmor[ id ] = true;
- }
- else NoPoints( id );
- }
- case 6: // Speed
- {
- if( iPlayerPoints[ id ] >= get_pcvar_num( speedcost ) )
- {
- set_user_maxspeed(id, 400.0)
- set_task(get_pcvar_float(time_speed), "remove_speed", id)
- iPlayerPoints[ id ] -= get_pcvar_num( speedcost );
- HasSpeed[ id ] = true;
- iSpeed[ id ] = true;
- ColorChat(0, TEAM_COLOR, "%s^x04 %s^x01 bought^x03 Speed^x01 from^x04 %d^x01 sek.", iPrefix, szName, get_pcvar_num(time_speed));
- }
- else NoPoints( id );
- }
- case 7: // Godmode
- {
- if( iPlayerPoints[ id ] >= get_pcvar_num( godmodecost ) )
- {
- set_user_godmode(id, 1);
- set_task(get_pcvar_float(time_godmode), "remove_godmode", id)
- iPlayerPoints[ id ] -= get_pcvar_num( godmodecost );
- HasGodmode[ id ] = true;
- ColorChat(0, TEAM_COLOR, "%s^x04 %s^x01 bought^x03 Godmode^x01 from^x04 %d^x01 sek.", iPrefix, szName, get_pcvar_num(time_godmode));
- }
- else NoPoints( id );
- }
- case 8: // Silent Walk
- {
- if( iPlayerPoints[ id ] >= get_pcvar_num( silentcost ) )
- {
- set_user_footsteps( id, 1 );
- set_task(get_pcvar_float(time_silent), "remove_silent", id)
- iPlayerPoints[ id ] -= get_pcvar_num( silentcost );
- HasSilent[ id ] = true;
- ColorChat(0, TEAM_COLOR, "%s^x04 %s^x01 bought^x03 Silent Walk^x01 from^x04 %d^x01 sek.", iPrefix, szName, get_pcvar_num(time_silent));
- }
- else NoPoints( id );
- }
- case 9: // AWP
- {
- if( iPlayerPoints[ id ] >= get_pcvar_num( awpcost ) )
- {
- if( user_has_weapon( id, CSW_AWP ) ) return PLUGIN_HANDLED;
- give_item(id, "weapon_awp");
- cs_set_weapon_ammo(find_ent_by_owner(1, "weapon_awp", id), get_pcvar_num(awp_ammo));
- cs_set_user_bpammo(id, CSW_AWP, 0);
- iPlayerPoints[ id ] -= get_pcvar_num( awpcost );
- HasAwp[ id ] = true;
- ColorChat(0, TEAM_COLOR, "%s^x04 %s^x01 Has bought^x03 AWP^x01!", iPrefix, szName);
- }
- else NoPoints( id );
- }
- case 10: // Deagle
- {
- if( iPlayerPoints[ id ] >= get_pcvar_num( deaglecost ) )
- {
- if( user_has_weapon( id, CSW_DEAGLE ) ) return PLUGIN_HANDLED;
- give_item(id, "weapon_deagle");
- cs_set_weapon_ammo(find_ent_by_owner(1, "weapon_deagle", id), get_pcvar_num(deagle_ammo));
- cs_set_user_bpammo(id, CSW_DEAGLE, 0);
- iPlayerPoints[ id ] -= get_pcvar_num( deaglecost );
- HasDeagle[ id ] = true;
- ColorChat(0, TEAM_COLOR, "%s^x04 %s^x01 Has bought^x03 Deagle^x01!", iPrefix, szName);
- }
- else NoPoints( id );
- }
- case 11: // Noclip
- {
- if( iPlayerPoints[ id ] >= get_pcvar_num( noclipcost ) )
- {
- set_user_noclip(id, 1);
- set_task(get_pcvar_float(time_noclip), "remove_noclip", id)
- iPlayerPoints[ id ] -= get_pcvar_num( noclipcost );
- HasNoclip[ id ] = true;
- ColorChat(0, TEAM_COLOR, "%s^x04 %s^x01 bought^x03 Noclip^x01 from^x04 %d^x01 sek.", iPrefix, szName, get_pcvar_num(time_noclip));
- }
- else NoPoints( id );
- }
- case 12: // Camouflage
- {
- if( iPlayerPoints[ id ] >= get_pcvar_num( camocost ) )
- {
- new oldModel[ 32 ];
- cs_get_user_model( id, oldModel, charsmax( oldModel ) );
- iCamoOldModel[ id ] = oldModel;
- cs_set_user_model( id, PlayerModels[ cs_get_user_team( id ) == CS_TEAM_CT ? random_num( 0, 3 ) : random_num( 4,7 ) ] );
- set_task(get_pcvar_float(time_camo), "remove_camouflage", id)
- iPlayerPoints[ id ] -= get_pcvar_num( camocost );
- HasCamo[ id ] = true;
- ColorChat(0, TEAM_COLOR, "%s^x04 %s^x01 bought^x03 Camouflage^x01 from^x04 %d^x01 sek.", iPrefix, szName, get_pcvar_num(time_camo));
- }
- else NoPoints( id );
- }
- }
- menu_destroy(shop)
- return PLUGIN_HANDLED;
- }
- NoPoints( id )
- {
- set_hudmessage( random( 256 ), random( 256 ), random( 256 ), 0.43, 0.55, 1, 5.0, 5.0, 0.1, 0.2, -1 );
- show_hudmessage( id, "You haven't got enough points!" );
- }
- NextUse( id ) ColorChat( id, GREEN, "%s^1 Next use, next round.", iPrefix );
- public remove_gravity(id)
- {
- if( is_user_connected( id ) && is_user_alive( id ) )
- {
- set_user_gravity(id, 1.0);
- ColorChat(id, GREEN, "%s^x03 Gravity^x01 is deactivate.", iPrefix);
- }
- }
- public remove_speed(id)
- {
- if( is_user_connected( id ) && is_user_alive( id ) )
- {
- set_user_maxspeed(id, 250.0);
- iSpeed[id] = false;
- ColorChat(id, GREEN, "%s^x01 Your speed is normal.", iPrefix);
- }
- }
- public remove_godmode(id)
- {
- if( is_user_connected( id ) && is_user_alive( id ) )
- {
- set_user_godmode(id, 0);
- ColorChat(id, GREEN, "%s^x03 Godmode^x01 is deactivate.", iPrefix);
- }
- }
- public remove_silent(id)
- {
- if( is_user_connected( id ) && is_user_alive( id ) )
- {
- set_user_footsteps( id, 0 );
- ColorChat(id, GREEN, "%s^x03 Silent Walk^x01 is deactivated.", iPrefix);
- }
- }
- public remove_noclip(id)
- {
- if( is_user_connected( id ) && is_user_alive( id ) )
- {
- set_user_noclip(id, 0);
- ColorChat(id, GREEN, "%s^x03 Noclip^x01 is deactivate.", iPrefix);
- }
- }
- public remove_camouflage(id)
- {
- if( is_user_connected( id ) && is_user_alive( id ) )
- {
- cs_set_user_model(id, iCamoOldModel[id]);
- ColorChat(id, GREEN, "%s^x03 Camouflage^x01 is deactivate.", iPrefix);
- }
- }
- public Advert()
- {
- ColorChat(0, GREEN, "%s^x01 This server is using^x03 %s v%s^x01 by^x03 %s", iPrefix, PLUGIN, VERSION, AUTHOR);
- ColorChat(0, GREEN, "%s^x01 Type^x03 /shop^x01 or^x03 /knifeshop^x01 to buy items.", iPrefix );
- }
- public EventCurWeapon(id)
- {
- if(is_user_connected( id ) && iSpeed[id]) set_user_maxspeed(id, 400.0);
- }
- LoadPoints( id )
- {
- if( !is_user_bot( id ) && !is_user_hltv( id ) )
- {
- new vaultkey[ 64 ], vaultdata[ 256 ], points[ 33 ], UserName[ 33 ];
- get_user_name( id, UserName, charsmax( UserName ) );
- format( vaultkey, charsmax( vaultkey ), "%s", UserName );
- format( vaultdata, charsmax( vaultdata ), "%i#", iPlayerPoints[ id ] );
- nvault_get( vault, vaultkey, vaultdata, 255 );
- replace_all( vaultdata, 255, "#", " " );
- parse( vaultdata, points, 32 );
- iPlayerPoints[ id ] = str_to_num( points );
- }
- }
- SavePoints( id )
- {
- if( !is_user_bot( id ) && !is_user_hltv( id ) )
- {
- new vaultkey[ 64 ], vaultdata[ 256 ], UserName[ 33 ];
- get_user_name( id, UserName, charsmax( UserName ) );
- format( vaultkey, charsmax( vaultkey ), "%s", UserName );
- format( vaultdata, charsmax( vaultdata ), "%i#", iPlayerPoints[ id ] );
- nvault_set( vault, vaultkey, vaultdata );
- }
- }
- HudColors( &r, &g, &b )
- {
- static szRed[ 5 ], szGreen[ 5 ], szBlue[ 5 ];
- new color[ 20 ];
- get_pcvar_string( hud_color, color, charsmax( color ) );
- parse( color, szRed, charsmax( szRed ), szGreen, charsmax( szGreen ), szBlue, charsmax( szBlue ) );
- r = str_to_num( szRed );
- g = str_to_num( szGreen );
- b = str_to_num( szBlue );
- }
- ColorChat(id, Color:type, const msg[], {Float,Sql,Result,_}:...)
- {
- static message[256];
- switch(type)
- {
- case NORMAL:
- {
- message[0] = 0x01;
- }
- case GREEN:
- {
- message[0] = 0x04;
- }
- default:
- {
- message[0] = 0x03;
- }
- }
- vformat(message[1], 251, msg, 4);
- message[192] = '^0';
- static team, ColorChange, index, MSG_Type;
- if(id)
- {
- MSG_Type = MSG_ONE;
- index = id;
- }
- else
- {
- index = FindPlayer();
- MSG_Type = MSG_ALL;
- }
- team = get_user_team(index);
- ColorChange = ColorSelection(index, MSG_Type, type);
- ShowColorMessage(index, MSG_Type, message);
- if(ColorChange)
- {
- Team_Info(index, MSG_Type, TeamName[team]);
- }
- }
- ShowColorMessage(id, type, message[])
- {
- message_begin(type, get_user_msgid("SayText"), _, id);
- write_byte(id)
- write_string(message);
- message_end();
- }
- Team_Info(id, type, team[])
- {
- message_begin(type, get_user_msgid("TeamInfo"), _, id);
- write_byte(id);
- write_string(team);
- message_end();
- return 1;
- }
- ColorSelection(index, type, Color:Type)
- {
- switch(Type)
- {
- case RED:
- {
- return Team_Info(index, type, TeamName[1]);
- }
- case BLUE:
- {
- return Team_Info(index, type, TeamName[2]);
- }
- case GREY:
- {
- return Team_Info(index, type, TeamName[0]);
- }
- }
- return 0;
- }
- FindPlayer()
- {
- static i;
- i = -1;
- while(i <= get_maxplayers())
- {
- if(is_user_connected(++i))
- {
- return i;
- }
- }
- return -1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement