AlliedModders Donor
Join Date: Apr 2017
Location: Switzerland
|
12-09-2018
, 16:37
Kameha like goku or végéta
|
#1
|
Hello, Eyal282 did this plugin for me, but we have a problem.
When player start kameha sometimes beam not appear, and when beam not appear sometimes make dommages sometimes no make dommages.
Do you have any idea how to fix this problem?
PHP Code:
#include <sourcemod>
#include <sdktools>
#include <sdkhooks>
Hello, à coder did this script for me, to start kamehameha like goku or vegeta. But we have a problem, sometimes sound is emitted but beam not appear and make damages sometimes when beam not appear sometimes no.
Do you have an idea to solve this plugin.
#include <cstrike>
#include <clientprefs>
new RingBeamModel, RingHaloModel;
new Handle:TIMER_KAMEHAME[MAXPLAYERS+1] = INVALID_HANDLE;
new const String:PLUGIN_VERSION[] = "1.0";
new g_bNeedsFakePrecache, g_bCheckedEngine
new GlobalColor[MAXPLAYERS+1][4], String:GlobalSound[MAXPLAYERS+1][50], String:GlobalName[MAXPLAYERS+1][50];
public Plugin:myinfo =
{
name = "Kamehame",
author = "Eyal282",
description = "HAAAAAAAAAAAAAAAAAA",
version = PLUGIN_VERSION,
url = "None."
}
new Float:NextKamehame[MAXPLAYERS+1];
new Float:NextKamehameSpamCheck[MAXPLAYERS+1];
public OnPluginStart()
{
HookEvent("player_spawn", Event_PlayerSpawn, EventHookMode_Post);
}
public void round_start(Handle event, const char[] name, bool dbc)
{
CreateTimer(25.0, RoundMsg);
}
public Action:RoundMsg(Handle timer)
{
for(new i=1;i <= MaxClients;i++)
{
if(!IsClientInGame(i))
continue;
else if(!IsPlayerAlive(i))
continue;
else if(!IsKamehameModel(i))
continue;
PrintCenterText(i, "PRESS E + R TO UNLEASH %s !", GlobalName[i]);
}
}
public Action:Event_PlayerSpawn(Handle:hEvent, const String:Name[], bool:dontBroadcast)
{
new client = GetClientOfUserId(GetEventInt(hEvent, "userid"));
if(client == 0)
return;
NextKamehame[client] = 0.0;
NextKamehameSpamCheck[client] = 0.0;
if(TIMER_KAMEHAME[client] != INVALID_HANDLE)
{
CloseHandle(TIMER_KAMEHAME[client]);
TIMER_KAMEHAME[client] = INVALID_HANDLE;
}
}
public OnClientDisconnected(client)
{
if(TIMER_KAMEHAME[client] != INVALID_HANDLE)
{
CloseHandle(TIMER_KAMEHAME[client]);
TIMER_KAMEHAME[client] = INVALID_HANDLE;
}
}
public Action:OnPlayerRunCmd(client, &buttons, &impulse, Float:vel[3], Float:angles[3], &weapon, &subtype, &cmdnum, &tickcount, &seed, mouse[2])
{
if(!(buttons & IN_USE))
return Plugin_Continue;
else if(!(buttons & IN_RELOAD))
return Plugin_Continue;
else if(!IsPlayerAlive(client))
return Plugin_Continue;
else if(!IsKamehameModel(client))
return Plugin_Continue;
else if(TIMER_KAMEHAME[client] != INVALID_HANDLE)
return Plugin_Continue;
new Float:GamTime = GetGameTime();
if(NextKamehame[client] > GamTime)
{
if(NextKamehameSpamCheck[client] < GamTime)
{
PrintToChat(client, "[IDEAS] \x07 You can kamehameha in %.1f seconds", NextKamehame[client] - GamTime);
NextKamehameSpamCheck[client] = GamTime + 5.0;
}
return Plugin_Continue;
}
NextKamehame[client] = GamTime + 300.0;
NextKamehameSpamCheck[client] = GamTime + 3.0;
new Float:Origin[3];
GetEntPropVector(client, Prop_Data, "m_vecOrigin", Origin);
EmitSoundToAllAny(GlobalSound[client], client, SNDCHAN_AUTO, 100, _, 1.0, 100, _, Origin);
TIMER_KAMEHAME[client] = CreateTimer(3.0, Kamehame, GetClientUserId(client), TIMER_FLAG_NO_MAPCHANGE);
PrintToChatAll("[IDEAS] \x07 %N is gonna unleash %s in 3 seconds!!!", client, GlobalName[client]);
return Plugin_Continue;
}
public OnMapStart()
{
RingBeamModel = PrecacheModel("materials/sprites/laserbeam.vmt", true);
RingHaloModel = PrecacheModel("materials/sprites/glow01.vmt", true);
PrecacheModel("models/error.mdl", true);
PrecacheSoundAny("ideas/galickgun.mp3");
PrecacheSoundAny("ideas/kamehameha.mp3");
for(new i=0;i <= MAXPLAYERS;i++)
{
TIMER_KAMEHAME[i] = INVALID_HANDLE;
}
}
public Action:Kamehame(Handle:hTimer, UserId)
{
new client = GetClientOfUserId(UserId);
if(client == 0)
return Plugin_Continue;
TIMER_KAMEHAME[client] = INVALID_HANDLE;
if(!IsKamehameModel(client)) // Also sets global data.
return Plugin_Continue;
new Float:Origin[3], Float:Angles[3], Float:EndOrigin[3], Float:CompareOrigin[3];
GetClientEyePosition(client, Origin);
GetClientEyeAngles(client, Angles);
TR_TraceRayFilter(Origin, Angles, MASK_SHOT, RayType_Infinite, Trace_DontHitPlayers); //Start the trace
TR_GetEndPosition(EndOrigin);
new Handle:HitArray = CreateArray(1);
PushArrayCell(HitArray, client);
new bool:NeverEndingLoop = true;
while(NeverEndingLoop)
{
TR_TraceHullFilter(Origin, EndOrigin, Float:{-30.0, -30.0, 0.0}, Float:{30.0, 30.0, 0.0}, MASK_SHOT, Trace_DontHitPlayersTwice, HitArray);
TR_GetEndPosition(CompareOrigin);
new HitTarget = TR_GetEntityIndex();
if(IsPlayer(HitTarget))
PushArrayCell(HitArray, HitTarget);
else
{
TR_GetEndPosition(EndOrigin);
break;
}
}
new size = GetArraySize(HitArray);
for(new i=0;i < size;i++)
{
new target = GetArrayCell(HitArray, i);
if(GetClientTeam(target) == GetClientTeam(client))
RemoveFromArray(HitArray, i);
}
size = GetArraySize(HitArray);
new amountHurt = size - 1; // Exclude caster.
new Float:BeamWidth = 25.0;
new Float:BeamLife = 7.5;
TE_SetupBeamPoints(Origin, EndOrigin, RingBeamModel, RingHaloModel, 0, 50, BeamLife, BeamWidth, BeamWidth-0.1, 1, 20.0, GlobalColor[client], 120);
TE_SendToAll();
/*
float fMiddle[3];
int iEnt = CreateEntityByName("trigger_multiple");
Call_StartForward(hOnZoneCreated);
Call_PushString(sZoneName);
Call_Finish();
DispatchKeyValue(iEnt, "spawnflags", "64");
Format(sZoneName, sizeof(sZoneName), "sm_devzone %s", sZoneName);
DispatchKeyValue(iEnt, "targetname", sZoneName);
DispatchKeyValue(iEnt, "wait", "0");
DispatchSpawn(iEnt);
ActivateEntity(iEnt);
GetMiddleOfABox(fMins, fMaxs, fMiddle);
TeleportEntity(iEnt, fMiddle, NULL_VECTOR, NULL_VECTOR);
SetEntityModel(iEnt, sModel);
// Have the mins always be negative
fMins[0] = fMins[0] - fMiddle[0];
if (fMins[0] > 0.0)
fMins[0] *= -1.0;
fMins[1] = fMins[1] - fMiddle[1];
if (fMins[1] > 0.0)
fMins[1] *= -1.0;
fMins[2] = fMins[2] - fMiddle[2];
if (fMins[2] > 0.0)
fMins[2] *= -1.0;
// And the maxs always be positive
fMaxs[0] = fMaxs[0] - fMiddle[0];
if (fMaxs[0] < 0.0)
fMaxs[0] *= -1.0;
fMaxs[1] = fMaxs[1] - fMiddle[1];
if (fMaxs[1] < 0.0)
fMaxs[1] *= -1.0;
fMaxs[2] = fMaxs[2] - fMiddle[2];
if (fMaxs[2] < 0.0)
fMaxs[2] *= -1.0;
SetEntPropVector(iEnt, Prop_Send, "m_vecMins", fMins);
SetEntPropVector(iEnt, Prop_Send, "m_vecMaxs", fMaxs);
SetEntProp(iEnt, Prop_Send, "m_nSolidType", 2);
int iEffects = GetEntProp(iEnt, Prop_Send, "m_fEffects");
iEffects |= 32;
SetEntProp(iEnt, Prop_Send, "m_fEffects", iEffects);
HookSingleEntityOutput(iEnt, "OnStartTouch", EntOut_OnStartTouch);
HookSingleEntityOutput(iEnt, "OnEndTouch", EntOut_OnEndTouch);
*/
int ent2 = CreateEntityByName("trigger_multiple");
DispatchKeyValue(ent2, "spawnflags", "64");
DispatchKeyValue(ent2, "wait", "0");
DispatchSpawn(ent2);
ActivateEntity(ent2);
new String:iName[50];
Format(iName, sizeof(iName), "%s-#%d", GlobalName[client], GetClientUserId(client));
SetEntPropString(ent2, Prop_Data, "m_iName", iName);
new Float:fMins[3], Float:fMaxs[3];
fMins[0] = Origin[0] - 30.0;
fMins[1] = Origin[1] - 30.0;
fMins[2] = Origin[2];// - 1.0;
fMaxs[0] = EndOrigin[0] + 30.0;
fMaxs[1] = EndOrigin[1] + 30.0;
fMaxs[2] = EndOrigin[2];// + 5.0;
new Float:fMiddle[3];
GetMiddleOfABox(fMins, fMaxs, fMiddle);
TeleportEntity(ent2, fMiddle, NULL_VECTOR, NULL_VECTOR);
SetEntityModel(ent2, "models/error.mdl");
fMins[0] = fMins[0] - fMiddle[0];
if (fMins[0] > 0.0)
fMins[0] *= -1.0;
fMins[1] = fMins[1] - fMiddle[1];
if (fMins[1] > 0.0)
fMins[1] *= -1.0;
fMins[2] = fMins[2] - fMiddle[2];
if (fMins[2] > 0.0)
fMins[2] *= -1.0;
// And the maxs always be positive
fMaxs[0] = fMaxs[0] - fMiddle[0];
if (fMaxs[0] < 0.0)
fMaxs[0] *= -1.0;
fMaxs[1] = fMaxs[1] - fMiddle[1];
if (fMaxs[1] < 0.0)
fMaxs[1] *= -1.0;
fMaxs[2] = fMaxs[2] - fMiddle[2];
if (fMaxs[2] < 0.0)
fMaxs[2] *= -1.0;
SetEntPropVector(ent2, Prop_Send, "m_vecMins", fMins);
SetEntPropVector(ent2, Prop_Send, "m_vecMaxs", fMaxs);
SetEntProp(ent2, Prop_Send, "m_nSolidType", 2);
int iEffects = GetEntProp(ent2, Prop_Send, "m_fEffects");
iEffects |= 32;
SetEntProp(ent2, Prop_Send, "m_fEffects", iEffects);
HookSingleEntityOutput(ent2, "OnStartTouch", EntOut_OnStartTouch);
CreateTimer(BeamLife, KillTheBeam, EntIndexToEntRef(ent2), TIMER_FLAG_NO_MAPCHANGE);
if(amountHurt == 0)
PrintToChat(client, "[IDEAS] \x07 %s did not hit anybody initially", GlobalName[client]);
for(new i=0;i < GetArraySize(HitArray);i++) // Ignores first value as it's the caster
{
new target = GetArrayCell(HitArray, i);
PrintToChatAll("[IDEAS] \x07 %N was hit by %N's %s", target, client, GlobalName[client]);
SDKHooks_TakeDamage(target, client, client, 1000.0);
}
return Plugin_Continue;
}
public Action:KillTheBeam(Handle:hTimer, Ref)
{
new entity = EntRefToEntIndex(Ref);
if(Ref == INVALID_ENT_REFERENCE)
return;
AcceptEntityInput(entity, "Kill");
}
public void EntOut_OnStartTouch(const char[] output, int caller, int activator, float delay) {
if (activator < 1 || activator > MaxClients || !IsClientInGame(activator) || !IsPlayerAlive(activator))
return;
new String:iName[50];
GetEntPropString(caller, Prop_Data, "m_iName", iName, sizeof(iName));
new position = StrContains(iName, "#", false);
if(position == -1)
return;
Format(iName, sizeof(iName), iName[position+1]);
new client = GetClientOfUserId(StringToInt(iName));
if(client == 0)
return;
else if(GetClientTeam(activator) == GetClientTeam(client))
return;
SDKHooks_TakeDamage(activator, client, client, 1000.0);
PrintToChatAll("[IDEAS] \x07 %N was hit by %N's %s", activator, client, GlobalName[client]);
}
/*
public void EntOut_OnEndTouch(const char[] output, int caller, int activator, float delay) {
PrintToChatAll("[IDEAS] \x07 Unepic gamer moment");
if (activator < 1 || activator > MaxClients || !IsClientInGame(activator) || !IsPlayerAlive(activator))
return;
PrintToChat(activator, "[IDEAS] \x07 epic gamer moment");
}
*/
public bool:Trace_DontHitPlayers(entity, contentsMask, victim)
{
return !IsPlayer(entity);
}
public bool:Trace_DontHitPlayersTwice(entity, contentsMask, Handle:HitArray)
{
return (IsPlayer(entity) && FindValueInArray(HitArray, entity) == -1);
}
stock bool:IsPlayer(entity)
{
if(entity > MaxClients)
return false;
else if(entity < 1)
return false;
return true;
}
// [url]https://pastebin.com/CRPi91EC[/url]
stock TE_SetupBeamBall(const float vecLocation[3], const float vecAngle[3], const int colorA[4],float radius, float time, int steps)
{
float x, y, vecView[3],vecTop[3] = {0,...}, angle = 0.0;
float PI = 3.1415926535897932384626433832795;
float pos1[3];
float pos2[3];
vecTop = vecAngle;
vecView = vecAngle;
vecTop[0] += 90.0;
vecView[0] += 90.0;
vecView[1] += 90.0;
GetAngleVectors(vecView, vecView, NULL_VECTOR, NULL_VECTOR);
NormalizeVector(vecView,vecView);
ScaleVector(vecView, radius);
GetAngleVectors(vecTop, vecTop, NULL_VECTOR, NULL_VECTOR);
NormalizeVector(vecTop,vecTop);
ScaleVector(vecTop, radius);
//Create the start position for the first part of the beam
pos2[0] = vecLocation[0] + Cosine(angle) * vecView[0] + Sine(angle) * vecTop[0];
pos2[1] = vecLocation[1] + Cosine(angle) * vecView[1] + Sine(angle) * vecTop[1];
pos2[2] = vecLocation[2] + Cosine(angle) * vecView[2] + Sine(angle) * vecTop[2];
angle += PI / steps;
while (angle <= 2 * PI)
{
pos1[0] = vecLocation[0] + Cosine(angle) * vecView[0] + Sine(angle) * vecTop[0];
pos1[1] = vecLocation[1] + Cosine(angle) * vecView[1] + Sine(angle) * vecTop[1];
pos1[2] = vecLocation[2] + Cosine(angle) * vecView[2] + Sine(angle) * vecTop[2];
TE_SetupBeamPoints(pos1, pos2, BeamSpriteCircle, HaloSpriteCircle, 0, 0, time, 25.0, 25.0, 5, 0.0,colorA, 3);
TE_SendToAll();
pos2[0] = pos1[0];
pos2[1] = pos1[1];
pos2[2] = pos1[2];
angle += PI / steps;
}
}
// Also gets global stuff.
stock IsKamehameModel(client)
{
new String:ModelName[256];
GetEntityModel(client, ModelName, sizeof(ModelName));
for(new i=strlen(ModelName)-1;i > 0;i--)
{
if(ModelName[i] == '/')
{
Format(ModelName, sizeof(ModelName), ModelName[i+1]);
break;
}
}
if(StrEqual(ModelName, "vegeta.mdl"))
{
GlobalColor[client] = {240, 34, 220, 255};
GlobalSound[client] = "ideas/galickgun.mp3";
GlobalName[client] = "Galick Gun";
return true;
}
else if(StrEqual(ModelName, "goku.mdl"))
{
GlobalColor[client] = {117, 250, 243, 255};
GlobalSound[client] = "ideas/kamehameha.mp3";
GlobalName[client] = "Kamehame";
return true;
}
return false;
}
stock GetEntityModel(entity, String:Buffer[], length)
{
GetEntPropString(entity, Prop_Data, "m_ModelName", Buffer, length);
}
// Emit sound any.
stock EmitSoundToAllAny(const String:sample[],
entity = SOUND_FROM_PLAYER,
channel = SNDCHAN_AUTO,
level = SNDLEVEL_NORMAL,
flags = SND_NOFLAGS,
Float:volume = SNDVOL_NORMAL,
pitch = SNDPITCH_NORMAL,
speakerentity = -1,
const Float:origin[3] = NULL_VECTOR,
const Float:dir[3] = NULL_VECTOR,
bool:updatePos = true,
Float:soundtime = 0.0)
{
new clients[MaxClients];
new total = 0;
for (new i=1; i<=MaxClients; i++)
{
if (IsClientInGame(i))
{
clients[total++] = i;
}
}
if (!total)
{
return;
}
EmitSoundAny(clients, total, sample, entity, channel,
level, flags, volume, pitch, speakerentity,
origin, dir, updatePos, soundtime);
}
stock bool:PrecacheSoundAny( const String:szPath[], bool:preload=false)
{
EmitSoundCheckEngineVersion();
if (g_bNeedsFakePrecache)
{
return FakePrecacheSoundEx(szPath);
}
else
{
return PrecacheSound(szPath, preload);
}
}
stock static EmitSoundCheckEngineVersion()
{
if (g_bCheckedEngine)
{
return;
}
new EngineVersion:engVersion = GetEngineVersion();
if (engVersion == Engine_CSGO || engVersion == Engine_DOTA)
{
g_bNeedsFakePrecache = true;
}
g_bCheckedEngine = true;
}
stock static bool:FakePrecacheSoundEx( const String:szPath[] )
{
decl String:szPathStar[PLATFORM_MAX_PATH];
Format(szPathStar, sizeof(szPathStar), "*%s", szPath);
AddToStringTable( FindStringTable( "soundprecache" ), szPathStar );
return true;
}
stock EmitSoundAny(const clients[],
numClients,
const String:sample[],
entity = SOUND_FROM_PLAYER,
channel = SNDCHAN_AUTO,
level = SNDLEVEL_NORMAL,
flags = SND_NOFLAGS,
Float:volume = SNDVOL_NORMAL,
pitch = SNDPITCH_NORMAL,
speakerentity = -1,
const Float:origin[3] = NULL_VECTOR,
const Float:dir[3] = NULL_VECTOR,
bool:updatePos = true,
Float:soundtime = 0.0)
{
EmitSoundCheckEngineVersion();
decl String:szSound[PLATFORM_MAX_PATH];
if (g_bNeedsFakePrecache)
{
Format(szSound, sizeof(szSound), "*%s", sample);
}
else
{
strcopy(szSound, sizeof(szSound), sample);
}
EmitSound(clients, numClients, szSound, entity, channel, level, flags, volume, pitch, speakerentity, origin, dir, updatePos, soundtime);
}
stock void GetMiddleOfABox(const float vec1[3], const float vec2[3], float buffer[3]) {
float mid[3];
MakeVectorFromPoints(vec1, vec2, mid);
mid[0] = mid[0] / 2.0;
mid[1] = mid[1] / 2.0;
mid[2] = mid[2] / 2.0;
AddVectors(vec1, mid, buffer);
}
__________________
Last edited by vegeta1241; 12-09-2018 at 16:59.
|
|