Code:
#include <sourcemod>
#include <sdktools_functions>
#include <sdktools>
#define VERSION "1.0"
new Handle:hGameConf = INVALID_HANDLE; //*added =... from laser_tag.sp
new Handle:hGetWeaponPosition = INVALID_HANDLE; //*added =... from laser_tag.sp
new g_sprite; //*from laser_tag.sp
public OnMapStart() //*from laser_tag.sp
{
g_sprite = PrecacheModel("materials/effects/gunshiptracer.vmt");
}
public Plugin:myinfo =
{
name = "Tracers",
author = "ZERO <ibis>",
description = "Makes tracers follow bullets",
version = VERSION,
url = "www.ibisgaming.com"
};
// create convars and hook event
public OnPluginStart()
{
//*from laser_tag.sp
hGameConf = LoadGameConfigFile("laser_tag.games");
if(hGameConf == INVALID_HANDLE)
{
SetFailState("gamedata/laser_tag.games.txt not loadable");
}
// Prep some virtual SDK calls *from laser_tag.sp
StartPrepSDKCall(SDKCall_Player);
PrepSDKCall_SetFromConf(hGameConf, SDKConf_Virtual, "Weapon_ShootPosition");
PrepSDKCall_SetReturnInfo(SDKType_Vector, SDKPass_ByValue);
hGetWeaponPosition = EndPrepSDKCall();
HookEvent("bullet_impact",Fire);
}
public Fire(Handle:event,const String:name[],bool:dontBroadcast)
{
if(GetRandomInt(1, 10) <= 2)
{
new clientid = GetEventInt(event,"userid");
new client = GetClientOfUserId(clientid);
new Float:start[3];
SDKCall(hGetWeaponPosition, client, start);
new Float:end[3]; //consolidated from earlier code however simular to usage in laser_tag.sp
end[0] = GetEventFloat(event,"x");
end[1] = GetEventFloat(event,"y");
end[2] = GetEventFloat(event,"z");
// The following code moves the beam a little bit further away from the player *from laser_tag.sp
new Float:distance = GetVectorDistance( start, end );
// calculate the percentage between 0.4 and the actual distance *from laser_tag.sp
new Float:percentage = 0.4 / ( distance / 100 );
// we add the difference between origin and destination times the percentage to calculate the new origin *from laser_tag.sp
new Float:newstart[3];
newstart[0] = start[0] + ( ( end[0] - start[0] ) * percentage );
newstart[1] = start[1] + ( ( end[1] - start[1] ) * percentage ) - 0.08;
newstart[2] = start[2] + ( ( end[2] - start[2] ) * percentage );
new Float:life = 0.3; //*from laser_tag.sp
new Float:width = 1.0; //*from laser_tag.sp
new color[4]; //*from laser_tag.sp
color[0] = 255; //R
color[1] = 255; //G
color[2] = 255; //B
color[3] = 100; //transparency
BeamClient(newstart, end, g_sprite, 0, 0, 0, life, width, width, 1, 0.0, color, 1); //parts *from laser_tag.sp
BeamClient(end, newstart, g_sprite, 0, 0, 0, life, width+2, width+4, 1, 0.0, color, 6); //parts *from laser_tag.sp
}
}
BeamClient(const Float:start[3], const Float:end[3], ModelIndex, HaloIndex, StartFrame, FrameRate, Float:Life, Float:Width, Float:EndWidth, FadeLength, Float:Amplitude, const Color[4], Speed)
{
TE_SetupBeamPoints(start, end, ModelIndex, HaloIndex, StartFrame, FrameRate, Life, Width, EndWidth, FadeLength, Amplitude, Color, Speed);
TE_SendToAll();
}
You should notice that array usage is basically identical. You can use it the same way like new array[3] = {object,object2,object3}; if you want. However strings are handled in a way that still confuses me a bit. It looks like you can not really create an array of stings and that if you do you need a special method converter. Also when you make strings you must define the length like new String:mystring[256]; creates a 256byt string.