Guest User

Untitled

a guest
Dec 28th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.95 KB | None | 0 0
  1. #include < amxmodx >
  2. #include < cstrike >
  3. #include < fakemeta >
  4. #include < engine >
  5. #include < fun >
  6.  
  7.  
  8. #pragma semicolon 1
  9.  
  10. #define PLUGIN "Furien Christmas Gifts"
  11. #define VERSION "0.6.3"
  12.  
  13.  
  14. enum Color
  15. {
  16. NORMAL = 1, // Culoarea care o are jucatorul setata in cvar-ul scr_concolor.
  17. GREEN, // Culoare Verde.
  18. TEAM_COLOR, // Culoare Rosu, Albastru, Gri.
  19. GREY, // Culoarea Gri.
  20. RED, // Culoarea Rosu.
  21. BLUE, // Culoarea Albastru.
  22. };
  23.  
  24. new TeamName[ ][ ] =
  25. {
  26. "",
  27. "TERRORIST",
  28. "CT",
  29. "SPECTATOR"
  30. };
  31.  
  32. enum
  33. {
  34.  
  35. GIFT_HP,
  36. GIFT_AP,
  37. GIFT_HP_AP,
  38. GIFT_MONEY,
  39. GIFT_HE,
  40. BADGIFT_MONEY,
  41. BADGIFT_WEAPONS,
  42. BADGIFT_SLAP
  43.  
  44. }
  45.  
  46. new const g_szFmuGiftsModels[ 7 ][ ] =
  47. {
  48.  
  49. "models/fmu_gift_cyan.mdl",
  50. "models/fmu_gift_green.mdl",
  51. "models/fmu_gift_orange.mdl",
  52. "models/fmu_gift_pink.mdl",
  53. "models/fmu_gift_red.mdl",
  54. "models/fmu_gift_yellow.mdl",
  55. "models/fmu_gift_random.mdl"
  56.  
  57. };
  58.  
  59. new const g_iFmuGiftsColors[ 7 ][ 3 ] =
  60. {
  61. { 0, 255, 255 },
  62. { 0, 255, 125 },
  63. { 255, 125, 65 },
  64. { 255, 0, 125 },
  65. { 255, 25, 25 },
  66. { 255, 255, 0 },
  67. { 255, 255, 255 }
  68. };
  69.  
  70. new const FMU_TAG[ ] = "[Furien Gifts]";
  71. new const g_szGiftClassName[ ] = "FurienGift_byAskhanar";
  72.  
  73. // Nu modifica !!
  74. new Float:fMaxs[ 3 ] = { 14.0, 14.0, 35.0 };
  75. new Float:fMins[ 3 ] = { -14.0, -14.0, 0.0 };
  76. // Nu modifica !!
  77.  
  78. new gCvarGiftHP;
  79. new gCvarGiftAP;
  80. new gCvarGiftMoney;
  81. new gCvarGiftChance;
  82.  
  83.  
  84. public plugin_precache( )
  85. for( new i = 0; i < 7; i++ )
  86. precache_model( g_szFmuGiftsModels[ i ] );
  87.  
  88.  
  89. public plugin_init( )
  90. {
  91.  
  92. register_plugin( PLUGIN, VERSION, "Askhanar" );
  93.  
  94. gCvarGiftHP = register_cvar( "fmu_gifts_hp", "5" );
  95. gCvarGiftAP = register_cvar( "fmu_gifts_ap", "5" );
  96. gCvarGiftMoney = register_cvar( "fmu_gifts_money", "5500" );
  97. gCvarGiftChance = register_cvar( "fmu_gifts_chance", "75" );
  98.  
  99. register_event( "DeathMsg", "EventDeathMsg", "a" );
  100.  
  101. register_event( "HLTV", "DeleteAllGifts", "a", "1=0", "2=0" );
  102. register_event( "TextMsg", "DeleteAllGifts", "a", "2=#Game_will_restart_in" );
  103.  
  104. // Oprita.. ( cand omori ultimu jucator, pica cadoul dar e sters de chemarea eventului.. ).
  105. //register_logevent( "DeleteAllGifts", 2, "0=World triggered", "1=Round_Draw", "1=Round_End" );
  106.  
  107. register_touch( g_szGiftClassName, "player", "FwdPlayerTouchGift" );
  108.  
  109.  
  110. }
  111.  
  112. public EventDeathMsg( )
  113. {
  114.  
  115. new iKiller = read_data( 1 );
  116. new iVictim = read_data( 2 );
  117.  
  118. if( iVictim != iKiller )
  119. {
  120.  
  121. static iRandomChance;
  122. iRandomChance = random_num( 1, 100 );
  123.  
  124. static iChance;
  125. iChance = get_pcvar_num( gCvarGiftChance );
  126.  
  127. if( iRandomChance <= iChance )
  128. {
  129. new iParm[ 3 ];
  130.  
  131. new Float:fUserOrigin[ 3 ], iUserOrigin[ 3 ];
  132. pev(iVictim, pev_origin, fUserOrigin );
  133. FVecIVec( fUserOrigin, iUserOrigin );
  134.  
  135. iParm[ 0 ] = iUserOrigin[ 0 ];
  136. iParm[ 1 ] = iUserOrigin[ 1 ];
  137. iParm[ 2 ] = iUserOrigin[ 2 ];
  138.  
  139. set_task( 0.7, "CreateGift", _, iParm, 3 );
  140. }
  141.  
  142. }
  143.  
  144.  
  145.  
  146.  
  147. return 0;
  148. }
  149.  
  150. public CreateGift( iParm[ ] )
  151. {
  152. new iOrigin[ 3 ], Float:fOrigin[ 3 ];
  153.  
  154.  
  155. iOrigin[ 0 ] = iParm[ 0 ];
  156. iOrigin[ 1 ] = iParm[ 1 ];
  157. iOrigin[ 2 ] = iParm[ 2 ];
  158. IVecFVec( iOrigin, fOrigin );
  159.  
  160. new iEnt = create_entity( "info_target" );
  161. if ( !is_valid_ent(iEnt) ) return 0;
  162.  
  163. new iRandom = random_num( 0, 6 );
  164.  
  165. entity_set_string( iEnt, EV_SZ_classname, g_szGiftClassName );
  166. entity_set_origin( iEnt, fOrigin );
  167. entity_set_model( iEnt, g_szFmuGiftsModels[ iRandom ] );
  168. entity_set_int( iEnt, EV_INT_movetype, MOVETYPE_NONE );
  169. entity_set_int( iEnt, EV_INT_solid, SOLID_BBOX );
  170. entity_set_size( iEnt, fMins, fMaxs );
  171.  
  172. set_rendering( iEnt,
  173. kRenderFxGlowShell,
  174. g_iFmuGiftsColors[ iRandom ][ 0 ],
  175. g_iFmuGiftsColors[ iRandom ][ 1 ],
  176. g_iFmuGiftsColors[ iRandom ][ 2 ],
  177. kRenderNormal,
  178. 255 );
  179.  
  180. drop_to_floor( iEnt );
  181.  
  182. new Float:fVelocity[ 3 ];
  183. fVelocity[ 0 ] = ( random_float( 0.0, 256.0 ) - 128.0 );
  184. fVelocity[ 1 ] = ( random_float( 0.0, 256.0 ) - 128.0 );
  185. fVelocity[ 2 ] = ( random_float( 0.0, 300.0 ) + 75.0 );
  186.  
  187. entity_set_vector( iEnt, EV_VEC_velocity, fVelocity );
  188.  
  189. return 0;
  190. }
  191.  
  192. public DeleteAllGifts( )
  193. {
  194. new iFoundEntity;
  195.  
  196. while ( ( iFoundEntity = find_ent_by_class( iFoundEntity, g_szGiftClassName ) ) != 0 )
  197. {
  198. engfunc( EngFunc_RemoveEntity, iFoundEntity );
  199. }
  200.  
  201. }
  202.  
  203. public FwdPlayerTouchGift( const iEnt, const id )
  204. {
  205.  
  206. if( is_valid_ent( iEnt ) && is_user_alive( id ) )
  207. {
  208.  
  209. static iRandomChance;
  210. iRandomChance = random_num( 1, 100 );
  211. if( iRandomChance <= 90 )
  212. {
  213. new iRandomGift = random_num( GIFT_HP, GIFT_HE );
  214. while( iRandomGift == GIFT_HE && user_has_weapon( id, CSW_HEGRENADE ) )
  215. iRandomGift = random_num( GIFT_HP, GIFT_HE );
  216.  
  217. GivePlayerGift( id, iRandomGift );
  218. }
  219. else
  220. {
  221. new iRandomGift = random_num( BADGIFT_MONEY, BADGIFT_SLAP );
  222. while( iRandomGift == BADGIFT_MONEY && cs_get_user_money( id ) == 0 )
  223. iRandomGift = random_num( BADGIFT_MONEY, BADGIFT_SLAP );
  224.  
  225. GivePlayerGift( id, iRandomGift );
  226. }
  227.  
  228. remove_entity( iEnt );
  229.  
  230. }
  231.  
  232. return 0;
  233. }
  234.  
  235. public GivePlayerGift( id, const iGiftType )
  236. {
  237.  
  238. switch( iGiftType )
  239. {
  240.  
  241. case GIFT_HP:
  242. {
  243. set_user_health( id, get_user_health( id ) + get_pcvar_num( gCvarGiftHP ) );
  244. ColorChat( id, RED, "^x04%s^x01 Mosul ti-a oferit cadou^x03 %i HP^x01!", FMU_TAG, get_pcvar_num( gCvarGiftHP ) );
  245.  
  246. }
  247. case GIFT_AP:
  248. {
  249. set_user_armor( id, get_user_armor( id ) + get_pcvar_num( gCvarGiftAP ) );
  250. ColorChat( id, RED, "^x04%s^x01 Mosul ti-a oferit cadou^x03 %i AP^x01!", FMU_TAG, get_pcvar_num( gCvarGiftAP ) );
  251.  
  252. }
  253. case GIFT_HP_AP:
  254. {
  255. static iHP;
  256. iHP = get_pcvar_num( gCvarGiftHP );
  257. static iAP;
  258. iAP = get_pcvar_num( gCvarGiftAP );
  259. set_user_health( id, get_user_health( id ) + iHP );
  260. set_user_armor( id, get_user_armor( id ) + iAP );
  261.  
  262. ColorChat( id, RED, "^x04%s^x01 Mosul ti-a oferit cadou^x03 %i HP^x01 si^x03 %i AP^x01!", FMU_TAG, iHP, iAP );
  263. }
  264. case GIFT_MONEY:
  265. {
  266. cs_set_user_money( id, clamp( cs_get_user_money( id ) + get_pcvar_num( gCvarGiftMoney ), 0, 16000 ) );
  267. ColorChat( id, RED, "^x04%s^x01 Mosul ti-a oferit cadou^x03 %i$^x01!", FMU_TAG, get_pcvar_num( gCvarGiftMoney ) );
  268. }
  269. case GIFT_HE:
  270. {
  271.  
  272. give_item( id, "weapon_hegrenade" );
  273. ColorChat( id, RED, "^x04%s^x01 Mosul ti-a oferit cadou un^x03 HE^x01!", FMU_TAG );
  274.  
  275. }
  276.  
  277. case BADGIFT_MONEY:
  278. {
  279. cs_set_user_money( id, 0 );
  280. ColorChat( id, RED, "^x04%s^x03 NU^x01 ai fost destul de^x03 cuminte^x01!", FMU_TAG );
  281. ColorChat( id, RED, "^x04%s^x01 Mosul ti-a confiscat toti banii!", FMU_TAG );
  282. }
  283. case BADGIFT_WEAPONS:
  284. {
  285. strip_user_weapons( id );
  286. give_item( id, "weapon_knife" );
  287. ColorChat( id, RED, "^x04%s^x03 NU^x01 ai fost destul de^x03 cuminte^x01!", FMU_TAG );
  288. ColorChat( id, RED, "^x04%s^x01 Mosul ti-a confiscat toate armele!", FMU_TAG );
  289. }
  290. case BADGIFT_SLAP:
  291. {
  292. set_task( 0.1, "PunchUser", id );
  293. set_task( 0.2, "PunchUser", id );
  294. set_task( 0.3, "PunchUser", id );
  295.  
  296. ColorChat( id, RED, "^x04%s^x03 NU^x01 ai fost destul de^x03 cuminte^x01!", FMU_TAG );
  297. ColorChat( id, RED, "^x04%s^x01 Mosul ti-a dat^x03 3^x01 palme!", FMU_TAG );
  298. }
  299. }
  300. }
  301.  
  302. public PunchUser( id )
  303. {
  304. if( !is_user_connected( id ) )
  305. return 1;
  306.  
  307. new Float:fRandomAngles[ 3 ];
  308. for(new i = 0; i < 3; i++)
  309. fRandomAngles[ i ] = random_float( 100.0, 150.0 );
  310.  
  311. entity_set_vector(id, EV_VEC_punchangle, fRandomAngles );
  312. user_slap( id, random_num( 1, 5 ) );
  313.  
  314. return 0;
  315. }
  316.  
  317.  
  318. ColorChat( id, Color:iType, const msg[ ], { Float, Sql, Result, _}:... )
  319. {
  320.  
  321. // Daca nu se afla nici un jucator pe server oprim TOT. Altfel dam de erori..
  322. if( !get_playersnum( ) ) return;
  323.  
  324. new szMessage[ 256 ];
  325.  
  326. switch( iType )
  327. {
  328. // Culoarea care o are jucatorul setata in cvar-ul scr_concolor.
  329. case NORMAL: szMessage[ 0 ] = 0x01;
  330.  
  331. // Culoare Verde.
  332. case GREEN: szMessage[ 0 ] = 0x04;
  333.  
  334. // Alb, Rosu, Albastru.
  335. default: szMessage[ 0 ] = 0x03;
  336. }
  337.  
  338. vformat( szMessage[ 1 ], 251, msg, 4 );
  339.  
  340. // Ne asiguram ca mesajul nu este mai lung de 192 de caractere.Altfel pica server-ul.
  341. szMessage[ 192 ] = '^0';
  342.  
  343.  
  344. new iTeam, iColorChange, iPlayerIndex, MSG_Type;
  345.  
  346. if( id )
  347. {
  348. MSG_Type = MSG_ONE_UNRELIABLE;
  349. iPlayerIndex = id;
  350. }
  351. else
  352. {
  353. iPlayerIndex = CC_FindPlayer( );
  354. MSG_Type = MSG_ALL;
  355. }
  356.  
  357. iTeam = get_user_team( iPlayerIndex );
  358. iColorChange = CC_ColorSelection( iPlayerIndex, MSG_Type, iType);
  359.  
  360. CC_ShowColorMessage( iPlayerIndex, MSG_Type, szMessage );
  361.  
  362. if( iColorChange ) CC_Team_Info( iPlayerIndex, MSG_Type, TeamName[ iTeam ] );
  363.  
  364. }
  365.  
  366. CC_ShowColorMessage( id, const iType, const szMessage[ ] )
  367. {
  368.  
  369. static bool:bSayTextUsed;
  370. static iMsgSayText;
  371.  
  372. if( !bSayTextUsed )
  373. {
  374. iMsgSayText = get_user_msgid( "SayText" );
  375. bSayTextUsed = true;
  376. }
  377.  
  378. message_begin( iType, iMsgSayText, _, id );
  379. write_byte( id );
  380. write_string( szMessage );
  381. message_end( );
  382. }
  383.  
  384. CC_Team_Info( id, const iType, const szTeam[ ] )
  385. {
  386. static bool:bTeamInfoUsed;
  387. static iMsgTeamInfo;
  388. if( !bTeamInfoUsed )
  389. {
  390. iMsgTeamInfo = get_user_msgid( "TeamInfo" );
  391. bTeamInfoUsed = true;
  392. }
  393.  
  394. message_begin( iType, iMsgTeamInfo, _, id );
  395. write_byte( id );
  396. write_string( szTeam );
  397. message_end( );
  398.  
  399. return 1;
  400. }
  401.  
  402. CC_ColorSelection( id, const iType, Color:iColorType)
  403. {
  404. switch( iColorType )
  405. {
  406.  
  407. case RED: return CC_Team_Info( id, iType, TeamName[ 1 ] );
  408. case BLUE: return CC_Team_Info( id, iType, TeamName[ 2 ] );
  409. case GREY: return CC_Team_Info( id, iType, TeamName[ 0 ] );
  410.  
  411. }
  412.  
  413. return 0;
  414. }
  415.  
  416. CC_FindPlayer( )
  417. {
  418. new iMaxPlayers = get_maxplayers( );
  419.  
  420. for( new i = 1; i <= iMaxPlayers; i++ )
  421. if( is_user_connected( i ) )
  422. return i;
  423.  
  424. return -1;
  425. }
Add Comment
Please, Sign In to add comment