PDA

View Full Version : Lock entity


iNexus
01-03-2012, 02:46
How to Lock an entity ?
this code is valide or not ?
stock LockingEntity()
{
for (new d=MaxClients; d <= entity; d++)
{
if (IsValidEdict(d) && IsValidEntity(d))
{
GetEdictClassname(d, entityLock, sizeof(entityLock));
if (StrEqual("Entity_name", entityLock))
{
SetEntProp(d, Prop_Data, "m_bLocked", 1, 1);
}
}
}
}Cordially,
iNex

Impact123
01-03-2012, 04:14
Im not familiar with SetEntProp and such stuff, so i only tell you the failures in the code in theory.
<= entity;where did you defined this?

GetEdictClassname(d, entityLock, sizeof(entityLock));Same here, i see no declaration of entityLock.

if (StrEqual("Entity_name", entityLock))You want to compare "Entity_name" with the entitys name?

I don't know what you want to achieve, but here is an example on how it would look like edited.


stock LockingEntity(const String:ClassName[])
{
new String:entityLock[SOME_SIZE];
for (new i=1; i <= MaxClients; i++)
{
if(IsValidEdict(i) && IsValidEntity(i))
{
GetEdictClassname(d, entityLock, sizeof(entityLock));
if(StrEqual(ClassName, entityLock))
{
SetEntProp(i, Prop_Data, "m_bLocked", 1, 1);
}
}
}
}
Yours sincerely
Impact

Silvers
01-03-2012, 06:28
Wouldn't this be better?

stock LockingEntity(const String:ClassName[])
{
new entity = -1;
while( (entity = FindEntityByClassName(entity, "Entity_Name")) != INVALID_ENT_REFERENCE )
{
if(IsValidEdict(entity) && IsValidEntity(entity))
{
SetEntProp(entity, Prop_Data, "m_bLocked", 1, 1);
}
}
}

Impact123
01-03-2012, 07:11
He wanted to know if his code is good or not, that's all i answered.

Yours sincerely
Impact

iNexus
01-03-2012, 07:30
Example:

//-----------------------------------
//------------ Include --------------
//-----------------------------------
#include <sourcemod>
#include <clients>
#include <colors>
#include <sdktools>
//-----------------------------------
//----------- Var & def -------------
//-----------------------------------
#define EK_Version "0.1B"
#define EK_Creator "iNex"
#define EK_Plugin_Name "Lock"
#define EK_Site ""
#define EK_desc ""

//Players Show number
new Li_Players, door;

//For door
new String:porte[800];

//-----------------------------------
//----------- Public var ------------
//-----------------------------------
public OnMapStart()
{
//Shear Number
Li_Players = GetMaxClients();
door = GetMaxEntities();
//For locking door
LockingDoor();
}

stock LockingDoor()
{
for (new d=Li_Players; d <= door; d++)
{
if (IsValidEdict(d) && IsValidEntity(d))
{
GetEdictClassname(d, porte, sizeof(porte));
if (StrEqual("func_door_rotating", porte) || StrEqual("prop_door_rotating", porte) || StrEqual("func_door", porte))
{
SetEntProp(d, Prop_Data, "m_bLocked", 1, 1);
}
}
}
}

lokizito
01-03-2012, 08:16
Silvers's code is the better way to go

stock LockingDoor()
{
LockingEntity("func_door_rotating");
LockingEntity("prop_door_rotating");
LockingEntity("func_door");
}

stock LockingEntity(const String:ClassName[])
{
new entity = -1;
while( (entity = FindEntityByClassName(entity, ClassName)) != INVALID_ENT_REFERENCE )
{
if(IsValidEdict(entity) && IsValidEntity(entity))
{
SetEntProp(entity, Prop_Data, "m_bLocked", 1, 1);
}
}
}

delachambre
01-04-2012, 08:17
Silvers's code is the better way to go

stock LockingDoor()
{
LockingEntity("func_door_rotating");
LockingEntity("prop_door_rotating");
LockingEntity("func_door");
}

stock LockingEntity(const String:ClassName[])
{
new entity = -1;
while( (entity = FindEntityByClassName(entity, ClassName)) != INVALID_ENT_REFERENCE )
{
if(IsValidEdict(entity) && IsValidEntity(entity))
{
SetEntProp(entity, Prop_Data, "m_bLocked", 1, 1);
}
}
}

Don't works ...

iNexus
01-04-2012, 08:30
For delachambre:
essaye ça comme j'ai pas de map avec des portes
stock LockingEntity(const String:ClassName[])
{
new entity = -1;
while((entity = FindEntityByClassname(entity, ClassName)) != INVALID_ENT_REFERENCE )
{
if(IsValidEdict(entity) && IsValidEntity(entity))
{
//SetEntProp(entity, Prop_Data, "m_bLocked", 1, 1);
Entity_AddFlags(entity, FL_FROZEN);
}
}
}

delachambre
01-04-2012, 08:38
Non plus

iNexus
01-04-2012, 08:50
Tu sais comment faire pour retirer les message comme : Player(iNex): lance une grenade

delachambre
01-04-2012, 08:57
Tu sais comment faire pour retirer les message comme : Player(iNex): lance une grenade

Revenons sur le sujet de départ.

delachambre
01-04-2012, 10:01
Preuve en screenshot :


http://nsa22.casimages.com/img/2012/01/04/120104041106725694.jpg (http://www.casimages.com)

La porte était ouverte au démarrage du serveur...

iNexus
01-04-2012, 11:06
For delachambre
t'arrive a les lock apres le lancement de la map ?

delachambre
01-04-2012, 11:45
Oui via mon /lock :)

iNexus
01-04-2012, 11:53
For Delechambre
le tiens ou celui de peace maker ?
soit y a une erreur dans le code depuis le depart et c'est ça qui fait tout foirer cherche l'erreur tu auras ton plugin

Impact123
01-04-2012, 11:59
Guys, please do me a favor, if a thread starts in english, keep it in that language.

Yours sincerely
Impact

delachambre
01-04-2012, 11:59
Le miens.

Je chercherais quand j'aurait le temps c'pas ma priorité.

EDIT : sorry Impact, a lot of code on this topic are down ...

iNexus
01-04-2012, 12:08
sorry Impact it's just a chat with two French coder