ttt_stocks.inc
Original include source with line numbers.
| 1 | #if defined _ttt_stocks_included |
| 2 | #endinput |
| 3 | #endif |
| 4 | #define _ttt_stocks_included |
| 5 | |
| 6 | #if !defined _ttt_included |
| 7 | #include <ttt> |
| 8 | #endif |
| 9 | |
| 10 | #define LOG_MSG_SIZE 200 |
| 11 | stock const death_messages[][] = |
| 12 | { |
| 13 | "TTT_KILL_SUICIDE", |
| 14 | "TTT_KILL_GENERIC", |
| 15 | "TTT_KILL_SLASH", |
| 16 | "TTT_KILL_BURN", |
| 17 | "TTT_KILL_FREEZE", |
| 18 | "TTT_KILL_FALL", |
| 19 | "TTT_KILL_BLAST", |
| 20 | "TTT_KILL_SHOCK", |
| 21 | "TTT_KILL_DROWN", |
| 22 | "TTT_KILL_NERVEGAS", |
| 23 | "TTT_KILL_POISON", |
| 24 | "TTT_KILL_RADIATION", |
| 25 | "TTT_KILL_ACID" |
| 26 | }; |
| 27 | |
| 28 | stock const special_names[][] = |
| 29 | { |
| 30 | "TTT_NONE", |
| 31 | "TTT_TRAITOR", |
| 32 | "TTT_DETECTIVE", |
| 33 | "TTT_INNOCENT", |
| 34 | "TTT_DEAD", |
| 35 | "TTT_SPECIAL" |
| 36 | }; |
| 37 | |
| 38 | stock const player_loyalty[][] = |
| 39 | { |
| 40 | "TTT_LOYALTY_NONE", |
| 41 | "TTT_LOYALTY_PROVABLE", |
| 42 | "TTT_LOYALTY_SUSPICIOUS", |
| 43 | "TTT_LOYALTY_AVOIDABLE", |
| 44 | "TTT_LOYALTY_TRAITOROUS" |
| 45 | }; |
| 46 | |
| 47 | stock is_dead_body(classname[]) |
| 48 | { |
| 49 | if(equal(classname, TTT_DEADBODY)) |
| 50 | return 1; |
| 51 | return 0; |
| 52 | } |
| 53 | |
| 54 | stock ttt_return_check(id) |
| 55 | { |
| 56 | new game = ttt_get_gamemode(); |
| 57 | if(!is_user_connected(id) || game == GAME_OFF || game == GAME_ENDED) |
| 58 | return 1; |
| 59 | |
| 60 | return 0; |
| 61 | } |
| 62 | |
| 63 | stock ttt_get_gamemode() |
| 64 | return ttt_get_globalinfo(GI_GAMEMODE); |
| 65 | |
| 66 | stock ttt_get_playerstate(id) |
| 67 | return ttt_get_playerdata(id, PD_PLAYERSTATE); |
| 68 | |
| 69 | stock ttt_is_exception(victim) |
| 70 | { |
| 71 | new item = ttt_get_playerdata(victim, PD_KILLEDBYITEM); |
| 72 | if(item > -1) |
| 73 | return ttt_find_exception(item); |
| 74 | |
| 75 | return 0; |
| 76 | } |
| 77 | |
| 78 | stock ttt_get_alivestate(id) |
| 79 | { |
| 80 | if(!is_user_alive(id)) |
| 81 | return ttt_get_playerdata(id, PD_KILLEDSTATE); |
| 82 | |
| 83 | return ttt_get_playerstate(id); |
| 84 | } |
| 85 | |
| 86 | stock ttt_get_user_name(id, name[], size) |
| 87 | { |
| 88 | new other_id = ttt_get_playerdata(id, PD_OTHERNAME); |
| 89 | if(!is_user_connected(other_id) || is_user_alive(other_id)) |
| 90 | { |
| 91 | other_id = id; |
| 92 | ttt_set_playerdata(id, PD_OTHERNAME, 0); |
| 93 | } |
| 94 | |
| 95 | get_user_name(other_id, name, size); |
| 96 | } |
| 97 | |
| 98 | stock ttt_state_special(player_state) |
| 99 | { |
| 100 | return player_state == PC_TRAITOR || player_state == PC_DETECTIVE; |
| 101 | } |
| 102 | |
| 103 | stock escape_mysql(string[], len) |
| 104 | { |
| 105 | replace_all(string, len, "\\", "\\\\"); |
| 106 | replace_all(string, len, "\0", "\\0"); |
| 107 | replace_all(string, len, "\n", "\\n"); |
| 108 | replace_all(string, len, "\r", "\\r"); |
| 109 | replace_all(string, len, "\x1a", "\Z"); |
| 110 | replace_all(string, len, "'", "\'"); |
| 111 | replace_all(string, len, "%", "\%"); |
| 112 | replace_all(string, len, "#", "\#"); |
| 113 | replace_all(string, len, ";", "\;"); |
| 114 | replace_all(string, len, "_", "\_"); |
| 115 | } |
| 116 | |
| 117 | stock auto_exec_config(const szName[]) |
| 118 | { |
| 119 | new szFileName[32]; |
| 120 | new iLen = copy(szFileName, charsmax(szFileName), szName); |
| 121 | if(iLen <= 4 || !equal(szFileName[iLen-4], ".cfg")) |
| 122 | add(szFileName, charsmax(szFileName), ".cfg"); |
| 123 | |
| 124 | new szConfigPath[96]; |
| 125 | get_localinfo("amxx_configsdir", szConfigPath, charsmax(szConfigPath)); |
| 126 | format(szConfigPath, charsmax(szConfigPath), "%s/%s", szConfigPath, szFileName); |
| 127 | |
| 128 | if(file_exists(szConfigPath)) |
| 129 | { |
| 130 | server_cmd("exec %s", szConfigPath); |
| 131 | server_exec(); |
| 132 | return 1; |
| 133 | } |
| 134 | |
| 135 | return 0; |
| 136 | } |
| 137 | |
| 138 | stock create_icon_origin(id, Float:origin[3], sprite, scale) // By sontung0 |
| 139 | { |
| 140 | if(!is_in_viewcone(id, origin)) |
| 141 | return; |
| 142 | |
| 143 | new Float:fMyOrigin[3]; |
| 144 | entity_get_vector(id, EV_VEC_origin, fMyOrigin); |
| 145 | |
| 146 | new Float:fMiddle[3], Float:fHitPoint[3]; |
| 147 | xs_vec_sub(origin, fMyOrigin, fMiddle); |
| 148 | trace_line(-1, fMyOrigin, origin, fHitPoint); |
| 149 | |
| 150 | new Float:fWallOffset[3], Float:fDistanceToWall; |
| 151 | fDistanceToWall = vector_distance(fMyOrigin, fHitPoint) - 10.0; |
| 152 | normalize(fMiddle, fWallOffset, fDistanceToWall); |
| 153 | |
| 154 | new Float:fSpriteOffset[3]; |
| 155 | xs_vec_add(fWallOffset, fMyOrigin, fSpriteOffset); |
| 156 | |
| 157 | te_sprite(id, fSpriteOffset, sprite, scale); |
| 158 | } |
| 159 | |
| 160 | stock te_sprite(id, Float:origin[3], sprite, scale) // By sontung0 |
| 161 | { |
| 162 | message_begin(MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, _, id); |
| 163 | write_byte(TE_SPRITE); |
| 164 | write_coord(floatround(origin[0])); |
| 165 | write_coord(floatround(origin[1])); |
| 166 | write_coord(floatround(origin[2])); |
| 167 | write_short(sprite); |
| 168 | write_byte(scale); |
| 169 | write_byte(255); |
| 170 | message_end(); |
| 171 | } |
| 172 | |
| 173 | stock normalize(Float:fIn[3], Float:fOut[3], Float:fMul) // By sontung0 |
| 174 | { |
| 175 | new Float:fLen = xs_vec_len(fIn); |
| 176 | xs_vec_copy(fIn, fOut); |
| 177 | |
| 178 | fOut[0] /= fLen, fOut[1] /= fLen, fOut[2] /= fLen; |
| 179 | fOut[0] *= fMul, fOut[1] *= fMul, fOut[2] *= fMul; |
| 180 | } |
| 181 | |
| 182 | stock ttt_is_jailmap() |
| 183 | { |
| 184 | static mapname[32]; |
| 185 | get_mapname(mapname, charsmax(mapname)); |
| 186 | |
| 187 | if(equali(mapname, "jail_", 5) || equali(mapname, "jb_", 3) || equali(mapname, "jailbreak_", 10)) |
| 188 | return 1; |
| 189 | |
| 190 | return 0; |
| 191 | } |
| 192 | |
| 193 | stock ttt_make_deathmsg(killer, victim, headshot, const weapon[], flags) |
| 194 | { |
| 195 | if(!is_user_connected(victim) || !is_user_connected(killer)) |
| 196 | return; |
| 197 | |
| 198 | static const cvar_state[] = |
| 199 | { |
| 200 | (1<<0), // a = PC_NONE, |
| 201 | (1<<1), // b = TRAITOR, |
| 202 | (1<<2), // c = DETECTIVE, |
| 203 | (1<<3), // d = INNOCENT, |
| 204 | (1<<4), // e = PC_DEAD, |
| 205 | (1<<5), // f = PC_SPECIAL, |
| 206 | (1<<6), // g = show victim |
| 207 | (1<<7) // h = show killer |
| 208 | }; |
| 209 | |
| 210 | static const size = PLAYER_CLASS+2; |
| 211 | new show[PLAYER_CLASS+2]; |
| 212 | for(new i; i < size; i++) |
| 213 | { |
| 214 | if(flags & cvar_state[i]) |
| 215 | show[i] = i; |
| 216 | } |
| 217 | |
| 218 | static msg; |
| 219 | if(!msg) |
| 220 | msg = get_user_msgid("DeathMsg"); |
| 221 | |
| 222 | static players[32]; |
| 223 | new i, j, should, specstate, num; |
| 224 | get_players(players, num); |
| 225 | for(--num; num >= 0; num--) |
| 226 | { |
| 227 | i = players[num]; |
| 228 | specstate = ttt_get_playerstate(i); |
| 229 | |
| 230 | should = false; |
| 231 | if(i == victim && show[PLAYER_CLASS]) |
| 232 | should = true; |
| 233 | else if(i == killer && show[PLAYER_CLASS+1]) |
| 234 | should = true; |
| 235 | else |
| 236 | { |
| 237 | for(j = 0; j < PLAYER_CLASS; j++) |
| 238 | { |
| 239 | if(specstate == show[j]) |
| 240 | { |
| 241 | should = true; |
| 242 | break; |
| 243 | } |
| 244 | } |
| 245 | } |
| 246 | |
| 247 | if(should) |
| 248 | { |
| 249 | message_begin(MSG_ONE_UNRELIABLE, msg, _, i); |
| 250 | write_byte(killer); |
| 251 | write_byte(victim); |
| 252 | write_byte(headshot); |
| 253 | write_string(weapon); |
| 254 | message_end(); |
| 255 | } |
| 256 | } |
| 257 | } |
| 258 | |
| 259 | stock ttt_find_valid_killer(victim, killer) |
| 260 | { |
| 261 | new new_killer = ttt_get_playerdata(victim, PD_KILLEDBY); |
| 262 | return new_killer ? new_killer : killer; |
| 263 | } |
| 264 | |
| 265 | stock ttt_get_kill_message(victim, killer, message[], len, type=0) |
| 266 | { |
| 267 | if(!is_user_alive(victim)) |
| 268 | { |
| 269 | static const weapon_names[][] = |
| 270 | { |
| 271 | "suicide", "p228", "", "scout", "hegrenade", "xm1014", "c4", "mac10", "aug", "hegrenade", "elite", "fiveseven", |
| 272 | "ump45", "sg550", "galil", "famas", "usp", "glock18", "awp", "mp5navy", "m249", "m3", "m4a1", "tmp", "g3sg1", "hegrenade", |
| 273 | "deagle", "sg552", "ak47", "crowbar", "p90" |
| 274 | }; |
| 275 | |
| 276 | static weapmsg[32]; |
| 277 | new item_id = ttt_get_playerdata(victim, PD_KILLEDBYITEM); |
| 278 | if(item_id > -1) |
| 279 | ttt_get_item_name(item_id, weapmsg, charsmax(weapmsg)); |
| 280 | else |
| 281 | { |
| 282 | //killer = ttt_get_playerdata(victim, KILLEDBY); |
| 283 | new weap = ttt_get_playerdata(victim, PD_KILLEDWEAP); |
| 284 | if(weap >= 3000) |
| 285 | formatex(weapmsg, charsmax(weapmsg), "%L", LANG_PLAYER, death_messages[weap-3000]); |
| 286 | else formatex(weapmsg, charsmax(weapmsg), "%s", weapon_names[weap]); |
| 287 | } |
| 288 | |
| 289 | if(type) |
| 290 | { |
| 291 | if(is_user_connected(killer)) |
| 292 | { |
| 293 | static name[32]; |
| 294 | get_user_name(killer, name, charsmax(name)); |
| 295 | formatex(message, len, "[%L] %s with %s", LANG_PLAYER, special_names[ttt_get_alivestate(killer)], name, weapmsg); |
| 296 | } |
| 297 | else formatex(message, len, "%s", weapmsg); |
| 298 | } |
| 299 | else formatex(message, len, "%s", weapmsg); |
| 300 | |
| 301 | return 1; |
| 302 | } |
| 303 | |
| 304 | return 0; |
| 305 | } |
| 306 | |
| 307 | stock ttt_log_api_error(text[], plugin, params, any:...) |
| 308 | { |
| 309 | static plugin_name[32], msg[LOG_MSG_SIZE]; |
| 310 | get_plugin(plugin, plugin_name, charsmax(plugin_name)); |
| 311 | vformat(msg, charsmax(msg), text, 4); |
| 312 | ttt_log_to_file(LOG_ERROR, "%s (params %d, plugin: %s)", msg, params, plugin_name); |
| 313 | return 0; |
| 314 | } |
| 315 | |
| 316 | stock ttt_log_to_file(type, text[], any:...) |
| 317 | { |
| 318 | static msg[LOG_MSG_SIZE]; |
| 319 | vformat(msg, charsmax(msg), text, 3); |
| 320 | ttt_logging(type, msg); |
| 321 | } |
| 322 | |
| 323 | stock find_dead_body_1d(id, array[], count) |
| 324 | { |
| 325 | new Float:fOrigin[2][3], origin[3]; |
| 326 | entity_get_vector(id, EV_VEC_origin, fOrigin[0]); |
| 327 | get_user_origin(id, origin, 3); |
| 328 | IVecFVec(origin, fOrigin[1]); |
| 329 | if(get_distance_f(fOrigin[0], fOrigin[1]) > 60.0) |
| 330 | return 0; |
| 331 | |
| 332 | for(new ent, i = 0; i < count; i++) |
| 333 | { |
| 334 | ent = array[i]; |
| 335 | if(!is_valid_ent(ent) || !is_visible(id, ent)) |
| 336 | continue; |
| 337 | |
| 338 | if(get_dat_deadbody(ent, fOrigin[0], fOrigin[1])) |
| 339 | return ent; |
| 340 | } |
| 341 | |
| 342 | return 0; |
| 343 | } |
| 344 | |
| 345 | stock find_dead_body_2d(id, array[33][]) |
| 346 | { |
| 347 | new Float:fOrigin[2][3], origin[3]; |
| 348 | entity_get_vector(id, EV_VEC_origin, fOrigin[0]); |
| 349 | get_user_origin(id, origin, 3); |
| 350 | IVecFVec(origin, fOrigin[1]); |
| 351 | if(get_distance_f(fOrigin[0], fOrigin[1]) > 60.0) |
| 352 | return 0; |
| 353 | |
| 354 | for(new ent, i = 0; i < 33; i++) |
| 355 | { |
| 356 | ent = array[i][BODY_ENTID]; |
| 357 | if(!is_valid_ent(ent) || !is_visible(id, ent)) |
| 358 | continue; |
| 359 | |
| 360 | if(get_dat_deadbody(ent, fOrigin[0], fOrigin[1])) |
| 361 | return ent; |
| 362 | } |
| 363 | |
| 364 | return 0; |
| 365 | } |
| 366 | |
| 367 | stock get_dat_deadbody(ent, Float:startOrigin[3], Float:endOrigin[3]) |
| 368 | { |
| 369 | if(!is_valid_ent(ent)) |
| 370 | return false; |
| 371 | |
| 372 | new ptr = create_tr2(); |
| 373 | engfunc(EngFunc_TraceModel, startOrigin, endOrigin, HULL_POINT, ent, ptr); |
| 374 | if(get_tr2(ptr, TR_pHit) == ent) |
| 375 | { |
| 376 | free_tr2(ptr); |
| 377 | return true; |
| 378 | } |
| 379 | |
| 380 | free_tr2(ptr); |
| 381 | return false; |
| 382 | } |
| 383 | |
| 384 | stock set_attrib_all(id, msg) |
| 385 | { |
| 386 | if(!is_user_connected(id)) |
| 387 | return; |
| 388 | |
| 389 | static g_Msg_ScoreAttrib; |
| 390 | if(!g_Msg_ScoreAttrib) |
| 391 | g_Msg_ScoreAttrib = get_user_msgid("ScoreAttrib"); |
| 392 | |
| 393 | message_begin(MSG_BROADCAST, g_Msg_ScoreAttrib); |
| 394 | write_byte(id); |
| 395 | write_byte(msg); |
| 396 | message_end(); |
| 397 | } |
| 398 | |
| 399 | stock set_attrib_special(id, msg, special1, special2=-1, special3=-1, special4=-1) |
| 400 | { |
| 401 | if(!is_user_connected(id)) |
| 402 | return; |
| 403 | |
| 404 | static g_Msg_ScoreAttrib; |
| 405 | if(!g_Msg_ScoreAttrib) |
| 406 | g_Msg_ScoreAttrib = get_user_msgid("ScoreAttrib"); |
| 407 | |
| 408 | new num, i, specstate; |
| 409 | static players[32]; |
| 410 | get_players(players, num); |
| 411 | for(--num; num >= 0; num--) |
| 412 | { |
| 413 | i = players[num]; |
| 414 | specstate = ttt_get_playerstate(i); |
| 415 | if(specstate == special1 || specstate == special2 || specstate == special3 || specstate == special4) |
| 416 | { |
| 417 | message_begin(MSG_ONE_UNRELIABLE, g_Msg_ScoreAttrib, _, i); |
| 418 | write_byte(id); |
| 419 | write_byte(msg); |
| 420 | message_end(); |
| 421 | } |
| 422 | } |
| 423 | } |
| 424 | |
| 425 | stock move_grenade() |
| 426 | { |
| 427 | new ent = -1; |
| 428 | while((ent = find_ent_by_class(ent, "grenade"))) |
| 429 | { |
| 430 | if(is_valid_ent(ent)) |
| 431 | entity_set_origin(ent, Float:{-8191.0, -8191.0, -8191.0}); |
| 432 | } |
| 433 | |
| 434 | return 1; |
| 435 | } |
| 436 | |
| 437 | stock my_register_cvar(name[], string[], description[], flags = 0, Float:fvalue = 0.0) |
| 438 | { |
| 439 | ttt_register_cvar(name, string, description); |
| 440 | return register_cvar(name, string, flags, fvalue); |
| 441 | } |
| 442 | |
| 443 | stock get_weapon_owner(ent) |
| 444 | return get_pdata_cbase(ent, 41, 4); |
| 445 | |
| 446 | stock strip_weapons(id) |
| 447 | { |
| 448 | if(!is_user_alive(id)) |
| 449 | return; |
| 450 | |
| 451 | static const PRIMARY_WEAPONS_BIT_SUM = (1<<CSW_SCOUT)|(1<<CSW_XM1014)|(1<<CSW_MAC10)|(1<<CSW_AUG)|(1<<CSW_UMP45)|(1<<CSW_SG550)|(1<<CSW_GALIL)|(1<<CSW_FAMAS)| |
| 452 | (1<<CSW_AWP)|(1<<CSW_MP5NAVY)|(1<<CSW_M249)|(1<<CSW_M3)|(1<<CSW_M4A1)|(1<<CSW_TMP)|(1<<CSW_G3SG1)|(1<<CSW_SG552)|(1<<CSW_AK47)|(1<<CSW_P90); |
| 453 | static const SECONDARY_WEAPONS_BIT_SUM = (1<<CSW_P228)|(1<<CSW_ELITE)|(1<<CSW_FIVESEVEN)|(1<<CSW_USP)|(1<<CSW_GLOCK18)|(1<<CSW_DEAGLE); |
| 454 | static const GRENADES_WEAPONS_BIT_SUM = (1<<CSW_HEGRENADE)|(1<<CSW_FLASHBANG)|(1<<CSW_SMOKEGRENADE)|(1<<CSW_C4); |
| 455 | new weapons[32], num_weapons, index, weaponid; |
| 456 | get_user_weapons(id, weapons, num_weapons); |
| 457 | |
| 458 | static wname[32]; |
| 459 | for (index = 0; index < num_weapons; index++) |
| 460 | { |
| 461 | weaponid = weapons[index]; |
| 462 | |
| 463 | if(((1<<weaponid) & PRIMARY_WEAPONS_BIT_SUM) || ((1<<weaponid) & SECONDARY_WEAPONS_BIT_SUM) || ((1<<weaponid) & GRENADES_WEAPONS_BIT_SUM)) |
| 464 | { |
| 465 | get_weaponname(weaponid, wname, charsmax(wname)); |
| 466 | |
| 467 | ham_strip_weapon(id, wname); |
| 468 | cs_set_user_bpammo(id, weaponid, 0); |
| 469 | } |
| 470 | } |
| 471 | |
| 472 | set_pdata_float(id, 116, 0.0); // m_fHasPrimary |
| 473 | remove_user_shield(id); |
| 474 | } |
| 475 | |
| 476 | stock ham_strip_weapon(id, const weapon[]) |
| 477 | { |
| 478 | if(!is_user_alive(id)) |
| 479 | return 0; |
| 480 | |
| 481 | new weapon_ent = find_ent_by_owner(-1, weapon, id); |
| 482 | if(!weapon_ent) |
| 483 | return 0; |
| 484 | |
| 485 | new weapon_id = get_weaponid(weapon); |
| 486 | if(!weapon_id) |
| 487 | return 0; |
| 488 | |
| 489 | if(get_user_weapon(id) == weapon_id) |
| 490 | ExecuteHamB(Ham_Weapon_RetireWeapon, weapon_ent); |
| 491 | |
| 492 | if(!ExecuteHamB(Ham_RemovePlayerItem, id, weapon_ent)) |
| 493 | return 0; |
| 494 | |
| 495 | user_has_weapon(id, weapon_id, 0); |
| 496 | ExecuteHamB(Ham_Item_Kill, weapon_ent); |
| 497 | remove_user_shield(id); |
| 498 | //set_pev(id, pev_weapons, pev(id, pev_weapons) & ~(1<<weapon_id)); |
| 499 | |
| 500 | return 1; |
| 501 | } |
| 502 | |
| 503 | stock ham_give_weapon(id, weapon[], val = 0) |
| 504 | { |
| 505 | if(!is_user_alive(id)) |
| 506 | return 0; |
| 507 | |
| 508 | if(!equal(weapon, "weapon_", 7)) |
| 509 | return 0; |
| 510 | |
| 511 | new ent = create_entity(weapon); |
| 512 | if(!is_valid_ent(ent)) |
| 513 | return 0; |
| 514 | |
| 515 | entity_set_int(ent, EV_INT_spawnflags, SF_NORESPAWN); |
| 516 | DispatchSpawn(ent); |
| 517 | |
| 518 | if(!ExecuteHamB(Ham_AddPlayerItem, id, ent)) |
| 519 | { |
| 520 | if(is_valid_ent(ent)) |
| 521 | entity_set_int(ent, EV_INT_flags, entity_get_int(ent, EV_INT_flags) | FL_KILLME); |
| 522 | return 0; |
| 523 | } |
| 524 | |
| 525 | ExecuteHamB(Ham_Item_AttachToPlayer, ent, id); |
| 526 | if(val && !is_user_bot(id)) |
| 527 | //ExecuteHamB(Ham_Item_Deploy, fm_find_ent_by_owner(-1, weapon, id)); |
| 528 | show_weapon(id, weapon); |
| 529 | |
| 530 | return ent; |
| 531 | } |
| 532 | |
| 533 | stock show_weapon(id, weapon[]) |
| 534 | { |
| 535 | static msg; |
| 536 | if(!msg) |
| 537 | msg = get_user_msgid("CurWeapon"); |
| 538 | |
| 539 | new weaponid = get_weaponid(weapon); |
| 540 | if(user_has_weapon(id, weaponid)) |
| 541 | ExecuteHamB(Ham_Item_Deploy, find_ent_by_owner(-1, weapon, id)); |
| 542 | |
| 543 | engclient_cmd(id, weapon); |
| 544 | |
| 545 | emessage_begin(MSG_ONE_UNRELIABLE, msg, _, id); |
| 546 | ewrite_byte(1); |
| 547 | ewrite_byte(weaponid); |
| 548 | ewrite_byte(-1); |
| 549 | emessage_end(); |
| 550 | } |
| 551 | |
| 552 | stock remove_user_shield(id) |
| 553 | { |
| 554 | #if AMXX_VERSION_NUM >= 183 |
| 555 | if(get_pdata_bool(id, 2043)) //m_bHasShield |
| 556 | { |
| 557 | set_pdata_bool(id, 2043, false); //m_bHasShield |
| 558 | set_pdata_int(id, 116, 0); // m_fHasPrimary |
| 559 | set_pdata_bool(id, 2042, false); // m_bUsesShield |
| 560 | set_pev(id, pev_gamestate, 1); |
| 561 | new iHideHUD = get_pdata_int(id, 361); // m_iHideHUD |
| 562 | if(iHideHUD & (1<<7)) |
| 563 | set_pdata_int(id, 361, iHideHUD & ~(1<<7)); // m_iHideHUD |
| 564 | |
| 565 | return 1; |
| 566 | } |
| 567 | |
| 568 | #endif |
| 569 | return -id; |
| 570 | } |
| 571 | |
| 572 | stock is_holding_dna_scanner(id) |
| 573 | { |
| 574 | static DNAScannerID; |
| 575 | if(!DNAScannerID) |
| 576 | { |
| 577 | new name[TTT_ITEMLENGHT]; |
| 578 | formatex(name, charsmax(name), "%L", LANG_SERVER, "TTT_ITEM_ID5"); |
| 579 | DNAScannerID = ttt_get_item_id(name); |
| 580 | } |
| 581 | |
| 582 | if(get_user_weapon(id) == CSW_C4) |
| 583 | { |
| 584 | new ent = find_ent_by_owner(-1, "weapon_c4", id); |
| 585 | if(get_weapon_edict(ent, REPL_CSWA_SET) == 2 && get_weapon_edict(ent, REPL_CSWA_ITEMID) == DNAScannerID) |
| 586 | return 1; |
| 587 | } |
| 588 | |
| 589 | return 0; |
| 590 | } |
| 591 | |
| 592 | stock FixedUnsigned16(Float:value, scale) |
| 593 | { |
| 594 | new output; |
| 595 | output = floatround(value * scale); |
| 596 | if(output < 0) |
| 597 | output = 0; |
| 598 | if(output > 0xFFFF) |
| 599 | output = 0xFFFF; |
| 600 | |
| 601 | return output; |
| 602 | } |