Hi, I'm trying to make plugin that will give all players that are connected to server and are alive a shield.
I can do that part with checking if player is connected.
Problem is on maps like de_mirage you can't use shields. On maps with hostages everything is working correctly.
I checked if the shield that is created has prop CanBePickUp set to 1 and it has.
Code:
void ShieldsMode(){
for (int i = 1; i <= MaxClients; i++){
if(IsClientInGame(i) && !IsFakeClient(i) && IsPlayerAlive(i)){
int shield = GivePlayerItem(i, "weapon_shield");
PrintToServer("Shield: %d", GetEntData(shield, 2732, 1)); //prints 1
}
}
}
On
https://developer.valvesoftware.com/wiki/Weapon_shield there's said that:
Quote:
For this weapon to be purchasable and being able to pick it up, at least one func_hostage_rescue needs to be present in the map.
|
So I tried to create that entity when map starts
Code:
public void OnMapStart(){
int hostageIndex = CreateEntityByName("func_hostage_rescue");
if(hostageIndex != -1 && IsValidEntity(hostageIndex)){
DispatchKeyValue(hostageIndex, "m_iName", "hostage");
bool checkSpawn = DispatchSpawn(hostageIndex);
if(!checkSpawn){
PrintToServer("Can't spawn entity");
} else {
PrintToServer("Entity spawned");
ActivateEntity(hostageIndex);
}
}
}
It doesn't work.
My last try was giving shield to player active slot but it bugged out.
Maybe i'm doing something wrong with creating entity or maybe I should use timings. I never used them before and don't know how they work. I'm out of ideas.