new Handle:hDamage; new Handle:hRadius; new Handle:hSpeed; new Handle:hType; new Handle:hEnable; new Handle:hReplace; new Handle:hTeam; new Handle:hArc; new Handle:hAmmo; new Handle:hPrice; new Handle:hBuyZone; new Handle:hBuyTime;
new Float:MinNadeHull[3] = {-2.5, -2.5, -2.5}; new Float:MaxNadeHull[3] = {2.5, 2.5, 2.5}; new Float:MaxWorldLength; new Float:SpinVel[3] = {0.0, 0.0, 200.0}; new Float:SmokeOrigin[3] = {-30.0,0.0,0.0}; new Float:SmokeAngle[3] = {0.0,-180.0,0.0};
new NadeDamage; new NadeRadius; new Float:NadeSpeed; new NadeType; new Float:NadeArc; new String:ReplaceNade[50]; new NadeAllowTeam; new IsEnabled; new ArcEnabled; new NadeAmmo; new NadePrice; new BuyZone; new Float:BuyTime; new Float:BuyTimer;
new MissilesLeft[MAXPLAYERS+1];
public Plugin:myinfo = { name = "Homing Missiles", author = "Blodia", description = "Turns projectile weapons into homing missiles", version = "2.5", url = "" }
public OnPluginStart() { CreateConVar("missile_version", PLUGIN_VERSION, "Homing missile version", FCVAR_PLUGIN|FCVAR_NOTIFY|FCVAR_REPLICATED); hDamage = CreateConVar("missile_damage", "100", "Sets the maximum amount of damage the missiles can do", FCVAR_PLUGIN|FCVAR_NOTIFY|FCVAR_REPLICATED, true, 1.0); hRadius = CreateConVar("missile_radius", "350", "Sets the explosive radius of the missiles", FCVAR_PLUGIN|FCVAR_NOTIFY|FCVAR_REPLICATED, true, 1.0); hSpeed = CreateConVar("missile_speed", "500.0", "Sets the speed of the missiles", FCVAR_PLUGIN|FCVAR_NOTIFY|FCVAR_REPLICATED, true, 300.0 ,true, 3000.0); hType = CreateConVar("missile_type", "1", "Type of missile to use, 0 = dumb missiles, 1 = homing missiles, 2 = crosshair guided", FCVAR_PLUGIN|FCVAR_NOTIFY|FCVAR_REPLICATED, true, 0.0, true, 2.0); hEnable = CreateConVar("missile_enable", "1", "1 enables plugin, 0 disables plugin", FCVAR_PLUGIN|FCVAR_NOTIFY|FCVAR_REPLICATED, true, 0.0, true, 1.0); hReplace = CreateConVar("missile_replace", "0", "replace this weapon with missiles, 0 = grenade, 1 = flashbang, 2 = smoke", FCVAR_PLUGIN|FCVAR_NOTIFY|FCVAR_REPLICATED, true, 0.0, true, 2.0); hTeam = CreateConVar("missile_team", "0", "Which team can use missiles, 0 = any, 1 = only terrorists, 2 = only counter terrorists", FCVAR_PLUGIN|FCVAR_NOTIFY|FCVAR_REPLICATED, true, 0.0, true, 2.0); hArc = CreateConVar("missile_arc", "1", "1 enables the turning arc of missiles, 0 makes turning instant for missiles", FCVAR_PLUGIN|FCVAR_NOTIFY|FCVAR_REPLICATED, true, 0.0, true, 1.0); hAmmo = CreateConVar("missile_ammo", "0", "Number of projectiles that turn into missiles per player spawn, 0 is infinite", FCVAR_PLUGIN|FCVAR_NOTIFY|FCVAR_REPLICATED, true, 0.0); hPrice = CreateConVar("missile_price", "0", "Price to buy a missile, 0 turns picked up projectiles into missiles", FCVAR_PLUGIN|FCVAR_NOTIFY|FCVAR_REPLICATED, true, 0.0, true, 16000.0); hBuyZone = CreateConVar("missile_buyzone", "0", "1 players can only buy while in buyzone, 0 players can buy anywhere", FCVAR_PLUGIN|FCVAR_NOTIFY|FCVAR_REPLICATED, true, 0.0, true, 1.0); hBuyTime = CreateConVar("missile_buytime", "0.0", "Sets the amount of time after round start players can buy missiles, 0.0 is infinite buy time", FCVAR_PLUGIN|FCVAR_NOTIFY|FCVAR_REPLICATED, true, 0.0);
public Event_RoundStart(Handle:event, const String:name[], bool:dontBroadcast) { if (NadePrice && IsEnabled) { PrintToChatAll("\x04[Homing Missiles]\x05 Type !buymissile in chat to buy a missile for $%i.", NadePrice); }
public Action:Command_Say(client, const String:command[], argc) { new String:text[15]; GetCmdArg(1, text, sizeof(text));
if (!IsEnabled) { return Plugin_Continue; }
if (StrEqual(text, "!buymissile", false)) { if ((!GetEntProp(client, Prop_Send, "m_bInBuyZone")) && (BuyZone)) { PrintToChat(client, "\x04[Homing Missiles]\x05 You aren't in a buyzone"); return Plugin_Handled; }
if ((GetGameTime() > BuyTimer) && (BuyTime != 0.0)) { PrintToChat(client, "\x04[Homing Missiles]\x05 Buy time is up"); return Plugin_Handled; }
new ClientTeam = GetEntProp(client, Prop_Send, "m_iTeamNum"); if ((NadeAllowTeam != 1) && (NadeAllowTeam != ClientTeam)) { PrintToChat(client, "\x04[Homing Missiles]\x05 Your team can't buy missiles.");
return Plugin_Handled; }
if ((MissilesLeft [client]== NadeAmmo) && NadeAmmo) { PrintToChat(client, "\x04[Homing Missiles]\x05 You can't buy anymore, you have maximum ammo"); } else { new Cash = GetEntProp(client, Prop_Send, "m_iAccount");
if (Cash < NadePrice) { PrintToChat(client, "\x04[Homing Missiles]\x05 You don't have $%i to buy a missile", NadePrice); } else { Cash -= NadePrice; SetEntProp(client, Prop_Send, "m_iAccount", Cash); MissilesLeft[client]++; PrintToChat(client, "\x04[Homing Missiles]\x05 Missiles left = %i", MissilesLeft[client]);
new AmmoReserve; if (StrEqual("hegrenade_projectile", ReplaceNade, false)) { AmmoReserve = GetEntProp(client, Prop_Send, "m_iAmmo", 4, 11);
if (!AmmoReserve) { GivePlayerItem(client, "weapon_hegrenade"); }
new String:OutputString[50] = "OnUser1 !self:FireUser2::0.0:1"; SetVariantString(OutputString); AcceptEntityInput(entity, "AddOutput");
AcceptEntityInput(entity, "FireUser1"); } }
public InitMissile(const String:output[], caller, activator, Float:delay) { new NadeOwner = GetEntPropEnt(caller, Prop_Send, "m_hThrower");
// assume other plugins don't set this on any projectiles they create, this avoids conflicts. if (NadeOwner == -1) { return; }
//ignore the projectile if this team can't use missiles. new NadeTeam = GetEntProp(caller, Prop_Send, "m_iTeamNum"); if ((NadeAllowTeam != 1) && (NadeAllowTeam != NadeTeam)) { return; }
if (!MissilesLeft[NadeOwner]) { return; } else { MissilesLeft[NadeOwner]--; PrintToChat(NadeOwner, "\x04[Homing Missiles]\x05 Missiles left = %i", MissilesLeft[NadeOwner]); }
// stop the projectile thinking so it doesn't detonate. SetEntProp(caller, Prop_Data, "m_nNextThinkTick", -1); SetEntityMoveType(caller, MOVETYPE_FLY); SetEntityModel(caller, "models/weapons/w_missile_closed.mdl"); // make it spin correctly. SetEntPropVector(caller, Prop_Data, "m_vecAngVelocity", SpinVel); // stop it bouncing when it hits something SetEntPropFloat(caller, Prop_Send, "m_flElasticity", 0.0); SetEntPropVector(caller, Prop_Send, "m_vecMins", MinNadeHull); SetEntPropVector(caller, Prop_Send, "m_vecMaxs", MaxNadeHull);
// make the missile go towards the coordinates the player is looking at. new Float:NadePos[3]; GetEntPropVector(caller, Prop_Send, "m_vecOrigin", NadePos); new Float:OwnerAng[3]; GetClientEyeAngles(NadeOwner, OwnerAng); new Float:OwnerPos[3]; GetClientEyePosition(NadeOwner, OwnerPos); TR_TraceRayFilter(OwnerPos, OwnerAng, MASK_SOLID, RayType_Infinite, DontHitOwnerOrNade, caller); new Float:InitialPos[3]; TR_GetEndPosition(InitialPos); new Float:InitialVec[3]; MakeVectorFromPoints(NadePos, InitialPos, InitialVec); NormalizeVector(InitialVec, InitialVec); ScaleVector(InitialVec, NadeSpeed); new Float:InitialAng[3]; GetVectorAngles(InitialVec, InitialAng); TeleportEntity(caller, NULL_VECTOR, InitialAng, InitialVec);
new NadeTeam = GetEntProp(caller, Prop_Send, "m_iTeamNum");
if (NadeType > 0) { new Float:ClosestDistance = MaxWorldLength; decl Float:TargetVec[3];
// find closest enemy in line of sight. if (NadeType == 1) { new ClosestEnemy; new Float:EnemyDistance; for (new i = 1; i <= MaxClients; i++) { if (IsClientInGame(i) && IsPlayerAlive(i) && (GetClientTeam(i) != NadeTeam)) { decl Float:EnemyPos[3]; GetClientEyePosition(i, EnemyPos); TR_TraceHullFilter(NadePos, EnemyPos, MinNadeHull, MaxNadeHull, MASK_SOLID, DontHitOwnerOrNade, caller); if (TR_GetEntityIndex() == i) { EnemyDistance = GetVectorDistance(NadePos, EnemyPos); if (EnemyDistance < ClosestDistance) { ClosestEnemy = i; ClosestDistance = EnemyDistance; } } } } // no target found, continue along current trajectory. if (!ClosestEnemy) { AcceptEntityInput(caller, "FireUser1"); return; } else { decl Float:EnemyPos[3]; GetClientEyePosition(ClosestEnemy, EnemyPos); MakeVectorFromPoints(NadePos, EnemyPos, TargetVec); } }
// make the missile go towards the coordinates the player is looking at. else if (NadeType == 2) { new NadeOwner = GetEntPropEnt(caller, Prop_Send, "m_hThrower"); decl Float:OwnerAng[3]; GetClientEyeAngles(NadeOwner, OwnerAng); decl Float:OwnerPos[3]; GetClientEyePosition(NadeOwner, OwnerPos); TR_TraceRayFilter(OwnerPos, OwnerAng, MASK_SOLID, RayType_Infinite, DontHitOwnerOrNade, caller); decl Float:TargetPos[3]; TR_GetEndPosition(TargetPos); ClosestDistance = GetVectorDistance(NadePos, TargetPos); MakeVectorFromPoints(NadePos, TargetPos, TargetVec); }
decl Float:CurrentVec[3]; GetEntPropVector(caller, Prop_Send, "m_vecVelocity", CurrentVec); decl Float:FinalVec[3]; if (ArcEnabled && (ClosestDistance > 100.0)) { NormalizeVector(TargetVec, TargetVec); NormalizeVector(CurrentVec, CurrentVec); ScaleVector(TargetVec, NadeArc); AddVectors(TargetVec, CurrentVec, FinalVec); } // ignore turning arc if the missile is close to the enemy to avoid it circling them. else { FinalVec = TargetVec; }
и чтоб ненадо каждый раз писать в чат чтоб купить чтоб ракеты. Чтоб они были стандартно Пожалуйста помогите кому несложно
Добавлено (02.07.2013, 23:35) --------------------------------------------- И как вообще привязовать флаг к плагину скажите пожалуйста если несложно приведите пример
Значит ты не скомпилировал, не удалил старый плагин(достаточно smx файла) Держи
Нет я всё скомпилировал проверил старый тоже удалил помещаю твой smx в папку plugins перезапускаю сервер или меняю карту пишу в чат !buymissile и никакого эфекта такое Ощущение что плагин даже незагрузился в логах ошибок связаных с плагином нет