Quote:
Originally Posted by luis enrique
can be added with a color plugin to physics and Dynamic objects
saved
|
Of course you can assign color. You can assign color to any physical or dynamic object, and you can save it in a keyvalues file (.cfg file), and then load it in the map you want, with the position and the specified color.
There are plugins that store objects on the map.
Spawner Objects:
https://forums.alliedmods.net/showthread.php?t=127418
Fort Spawner:
https://forums.alliedmods.net/showthread.php?t=129603
Of course these plugins do not save the color but you can add that value to a key value in the files that these plugins generate.
A solution to your problem using the Spawner Objects plugin would look something like this:
This is an example of a bus that was saved on a map.
Code:
"Objects_Cache"
{
"object_1"
{
"origin" "123.000000 456.000000 789.000000"
"angles" "0.000000 95.502655 0.000000"
"model" "models/props_waterfront/tour_bus.mdl"
"classname" "prop_physics_override"
"rendercolor" "255 0 0 255" //I keep the color
}
}
To establish the color you can follow the advice of LenHard. It is one of the ways to establish color. Another would be:
Code:
void SetColorEntity(entity, String:strColor[])
{
if (IsValidEntity(entity))
{
DispatchKeyValue(entity, "rendercolor", strColor);
}
}
Now use this method in the place where the plugin gets the data from the keyvalues file. For you to understand me better, read about the keyvalues files.
If I want the Object Spawner plugin to assign color to the entity, it would be something like this:
PHP Code:
stock LoadPluginProps(client, number)
{
LogSpawn("%N loaded the objects for this map", client);
PrintToChat(client, "\x04[SM] Loading content. Please Wait");
new Handle:keyvalues = INVALID_HANDLE;
decl String:KvFileName[256], String:map[256], String:name[256];
GetCurrentMap(map, sizeof(map));
BuildPath(Path_SM, KvFileName, sizeof(KvFileName), "data/maps/plugin_cache/%s_%i.txt", map, number);
if(!FileExists(KvFileName))
{
PrintToChat(client, "\x04[SM] The file does not exist");
PrintHintText(client, "\x04[SM] The file does not exist");
return;
}
keyvalues = CreateKeyValues("Objects_Cache");
FileToKeyValues(keyvalues, KvFileName);
KvRewind(keyvalues);
if(KvJumpToKey(keyvalues, "total_cache"))
{
new max = KvGetNum(keyvalues, "total", 0);
if(max <= 0)
{
PrintToChat(client, "\x04[SM] No objects found in the cache");
return;
}
decl String:model[256], String:class[64], Float:vecOrigin[3], Float:vecAngles[3];
decl String:strColor; //Variable to store the color. Format RGBA
new solid;
KvRewind(keyvalues);
for(new count=1; count <= max; count++)
{
Format(name, sizeof(name), "object_%i", count);
if(KvJumpToKey(keyvalues, name))
{
solid = KvGetNum(keyvalues, "solid");
KvGetVector(keyvalues, "origin", vecOrigin);
KvGetVector(keyvalues, "angles", vecAngles);
KvGetString(keyvalues, "model", model, sizeof(model));
KvGetString(keyvalues, "classname", class, sizeof(class));
KvGetString(keyvalues, "rendercolor", strColor, sizeof(strColor)); // Here I get the color of the .cfg file
new prop = -1;
KvRewind(keyvalues);
if(StrContains(class, "prop_physics") >= 0)
{
prop = CreateEntityByName("prop_physics_override");
}
else
{
prop = CreateEntityByName("prop_dynamic_override");
SetEntProp(prop, Prop_Send, "m_nSolidType", solid);
}
DispatchKeyValue(prop, "model", model);
DispatchKeyValue(prop, "rendercolor", strColor); // Here I set the color to the entity in progress.
DispatchKeyValue(prop, "targetname", "l4d2_spawn_props_prop");
g_vecLastEntityAngles[client][0] = vecAngles[0];
g_vecLastEntityAngles[client][1] = vecAngles[1];
g_vecLastEntityAngles[client][2] = vecAngles[2];
DispatchKeyValueVector(prop, "angles", vecAngles);
DispatchSpawn(prop);
TeleportEntity(prop, vecOrigin, NULL_VECTOR, NULL_VECTOR);
g_bSpawned[prop] = true;
g_vecEntityAngles[prop] = vecAngles;
}
else
{
break;
}
}
}
CloseHandle(keyvalues);
PrintToChat(client, "\x03[SM] Succesfully loaded the map data");
PrintHintText(client, "[SM] If nothing is visible, you probably forgot something during installation");
}
Now if you want to obtain the color of an entity, it would be as follows:
Code:
void GetColorEntity(entity, String:strColor[], maxlength)
{
if (IsValidEntity(entity))
{
new r, g, b, a;
GetEntityRenderColor(entity, r, g, b, a);
Format(strColor, maxlength, "%d %d %d %d", r, g, b, a);
}
}
Check where the data saves the plugin you have to save the color. You can save it manually or using the plugin.
You can save the color, at the moment the plugin saves the object in a keyvalues file. It is similar to obtaining data, using the methods of keyvalues (keyvalues.inc) or also some plugins use the functions to save files offered by sourcemod (file.inc). Read the documentation of the sourcemod api for more information.
Greetings.
__________________