|
SourceMod Moderator
|
10-19-2016
, 14:23
Re: Does anyone has some good ideas what should i do with this.
|
#24
|
Sourcemod 1.7+
Code:
sm_crate - sets location and spawns crate (used twice)
sm_removecrates - removes all spawned crates
Spoiler
PHP Code:
#include <sourcemod>
#include <sdktools>
float ga_fClientPosition[MAXPLAYERS+1][3];
ArrayList entityArray;
public Plugin myinfo =
{
name = "[CS:GO] Weapon Crate Spawner",
author = "Headline",
description = "Spawns an enlarged weapon crate",
version = "1.0",
url = "colosseum-gaming.com"
}
public void OnPluginStart()
{
RegConsoleCmd("sm_crate", Command_Crate);
RegConsoleCmd("sm_removecrates", Command_Remove);
}
public void OnMapStart()
{
AddFileToDownloadsTable("models/custom_props/crates/weapon_crate.dx90.vtx")
AddFileToDownloadsTable("models/custom_props/crates/weapon_crate.mdl")
AddFileToDownloadsTable("models/custom_props/crates/weapon_crate.phy")
AddFileToDownloadsTable("models/custom_props/crates/weapon_crate.vvd")
PrecacheModel("models/custom_props/crates/weapon_crate.mdl")
entityArray = new ArrayList();
}
public Action Command_Crate(int client, int args)
{
if (!IsValidClient(client))
{
ReplyToCommand(client, "[SM] You must be ingame to use this command!");
return Plugin_Handled;
}
if (args != 0)
{
ReplyToCommand(client, "[SM] Usage: sm_crate");
return Plugin_Handled;
}
if (!IsPositionSaved(client))
{
GetClientAbsOrigin(client, ga_fClientPosition[client]);
ReplyToCommand(client, "[SM] Location saved. Re-type command to spawn!");
}
else
{
int entity;
entity = CreateEntityByName("prop_dynamic_override");
if (entity == -1)
{
ReplyToCommand(client, "[SM] Error creating entity.")
return Plugin_Handled;
}
SetEntityModel(entity, "models/custom_props/crates/weapon_crate.mdl");
DispatchKeyValue(entity, "solid", "1");
AcceptEntityInput(entity, "EnableCollision");
SetEntProp(entity, Prop_Data, "m_nSolidType", 6);
DispatchSpawn(entity);
TeleportEntity(entity, ga_fClientPosition[client], NULL_VECTOR, NULL_VECTOR);
ReplyToCommand(client, "[SM] Model spawned!");
Reset(client)
entityArray.Push(entity);
}
return Plugin_Handled;
}
public Action Command_Remove(int client, int args)
{
if (!IsValidClient(client))
{
ReplyToCommand(client, "[SM] You must be ingame to use this command!");
return Plugin_Handled;
}
if (args != 0)
{
ReplyToCommand(client, "[SM] Usage: sm_removecrates");
return Plugin_Handled;
}
int entity;
int count = 0;
for (int i = 0; i < entityArray.Length; i++)
{
entity = entityArray.Get(i);
if (IsValidEntity(entity))
{
AcceptEntityInput(entity, "kill");
count++;
}
}
entityArray.Clear();
ReplyToCommand(client, "[SM] Removed %i entities", count);
return Plugin_Handled;
}
void Reset(int client)
{
for (int i = 0; i < 3; i++)
{
ga_fClientPosition[client][i] = 0.0;
}
}
bool IsPositionSaved(int client)
{
bool isSaved = false;
for (int i = 0; i < 3; i++)
{
if (ga_fClientPosition[client][i] != 0.0)
{
isSaved = true;
}
}
return isSaved;
}
stock bool IsValidClient(client, bool bAllowBots = false, bool bAllowDead = true)
{
if(!(1 <= client <= MaxClients) || !IsClientInGame(client) || (IsFakeClient(client) && !bAllowBots) || IsClientSourceTV(client) || IsClientReplay(client) || (!bAllowDead && !IsPlayerAlive(client)))
{
return false;
}
return true;
}
Last edited by headline; 10-19-2016 at 14:39.
|
|
|
|