PDA

View Full Version : Special Zone-Plugin Feature


Tobiii_
06-25-2016, 02:17
Hey,
Im currently looking for a Plugin where Players inside a zone cant kill other Players inside the Zone, but Players outside the zone can kill players inside the zone and players inside the zone can kill players outside the zone.
I know there are a 2 plugins for zones but i havent found a feature for any plugin which do it like i want :). Im currently using this: https://forums.alliedmods.net/showthread.php?p=2023591
Sorry for my bad English :c
Greets
Tobi

Arkarr
06-25-2016, 05:39
I'll drop the code here.

Tobiii_
06-25-2016, 05:47
Thank you :)

Arkarr
06-25-2016, 11:59
Sorry, totally forgot about this thread :¬|.
Here we go :

#include <sourcemod>
#include <sdkhooks>
#include <devzones>

#define PLUGIN_AUTHOR "Arkarr"
#define PLUGIN_VERSION "1.00"
#define ZONE_TRIGGER "NDTO_"

bool CanDealDmg[MAXPLAYERS + 1];

public Plugin myinfo =
{
name = "[ANY] \"No dammage to other\" zones",
author = PLUGIN_AUTHOR,
description = "Disable dammage done to other players while inside a zone",
version = PLUGIN_VERSION,
url = "http://www.sourcemod.net"
};

public void OnPluginStart()
{
for (new i = 1; i <= MaxClients; i++)
{
if (IsClientInGame(i))
SDKHook(i, SDKHook_OnTakeDamage, OnTakeDamage);
}
}

public void OnClientPutInServer(int client)
{
CanDealDmg[client] = true;
SDKHook(client, SDKHook_OnTakeDamage, OnTakeDamage);
}

public Action OnTakeDamage(int victim, int &attacker, int &inflictor, float &damage, int &damagetype)
{
if(!CanDealDmg[attacker])
return Plugin_Handled;

return Plugin_Continue;
}

public Zone_OnClientEntry(int client, char[] zone)
{
if(StrContains(zone, ZONE_TRIGGER, false) == -1)
return;

CanDealDmg[client] = false;
}

public Zone_OnClientLeave(int client, char[] zone)
{
if (StrContains(zone, ZONE_TRIGGER, false) == -1)
return;

CanDealDmg[client] = true;
}


PS: If you want a zone wich trigger the effect you described above, the zone's name should start with "NDTO_". For exemple : NDTO_Zone1

Tobiii_
06-25-2016, 12:16
Sorry, totally forgot about this thread :¬|.
Here we go :

#include <sourcemod>
#include <sdkhooks>
#include <devzones>

#define PLUGIN_AUTHOR "Arkarr"
#define PLUGIN_VERSION "1.00"
#define ZONE_TRIGGER "NDTO_"

bool CanDealDmg[MAXPLAYERS + 1];

public Plugin myinfo =
{
name = "[ANY] \"No dammage to other\" zones",
author = PLUGIN_AUTHOR,
description = "Disable dammage done to other players while inside a zone",
version = PLUGIN_VERSION,
url = "http://www.sourcemod.net"
};

public void OnPluginStart()
{
for (new i = 1; i <= MaxClients; i++)
{
if (IsClientInGame(i))
SDKHook(i, SDKHook_OnTakeDamage, OnTakeDamage);
}
}

public void OnClientPutInServer(int client)
{
CanDealDmg[client] = true;
SDKHook(client, SDKHook_OnTakeDamage, OnTakeDamage);
}

public Action OnTakeDamage(int victim, int &attacker, int &inflictor, float &damage, int &damagetype)
{
if(!CanDealDmg[attacker])
return Plugin_Handled;

return Plugin_Continue;
}

public Zone_OnClientEntry(int client, char[] zone)
{
if(StrContains(zone, ZONE_TRIGGER, false) == -1)
return;

CanDealDmg[client] = false;
}

public Zone_OnClientLeave(int client, char[] zone)
{
if (StrContains(zone, ZONE_TRIGGER, false) == -1)
return;

CanDealDmg[client] = true;
}


PS: If you want a zone wich trigger the effect you described above, the zone's name should start with "NDTO_". For exemple : NDTO_Zone1


SourcePawn Compiler 1.7.1
Copyright (c) 1997-2006 ITB CompuPhase
Copyright (c) 2004-2014 AlliedModders LLC

/groups/sourcemod/upload_tmp/textYvacAG.sp(3) : fatal error 182: cannot read from file: "devzones"

Compilation aborted.
1 Error.

Im doin something wrong :c

Tobiii_
06-25-2016, 12:48
#pump

Tobiii_
06-25-2016, 13:10
I did it but u cant shoot out of the zone

Arkarr
06-25-2016, 16:56
I did it but u cant shoot out of the zone
Herm... My plugin doesn't block shots, it just block the damages.

Tobiii_
06-26-2016, 01:05
Herm... My plugin doesn't block shots, it just block the damages.


Yeah thats what i mean. xD but you cant do damge to players outside a zone when you are inside a zone

Arkarr
06-26-2016, 03:17
Yeah thats what i mean. xD but you cant do damge to players outside a zone when you are inside a zone
My bad, didn't fully understood your post. I'll fix my code.

EDIT:

#include <sourcemod>
#include <sdkhooks>
#include <devzones>

#define PLUGIN_AUTHOR "Arkarr"
#define PLUGIN_VERSION "1.00"
#define ZONE_TRIGGER "NDTO_"

bool InsideZone[MAXPLAYERS + 1];

public Plugin myinfo =
{
name = "[ANY] \"No dammage to other\" zones",
author = PLUGIN_AUTHOR,
description = "Disable dammage done to other players while inside a zone",
version = PLUGIN_VERSION,
url = "http://www.sourcemod.net"
};

public void OnPluginStart()
{
for (new i = 1; i <= MaxClients; i++)
{
if (IsClientInGame(i))
SDKHook(i, SDKHook_OnTakeDamage, OnTakeDamage);
}
}

public void OnClientPutInServer(int client)
{
InsideZone[client] = false;
SDKHook(client, SDKHook_OnTakeDamage, OnTakeDamage);
}

public Action OnTakeDamage(int victim, int &attacker, int &inflictor, float &damage, int &damagetype)
{
if(InsideZone[attacker] && InsideZone[victim])
return Plugin_Handled;

return Plugin_Continue;
}

public Zone_OnClientEntry(int client, char[] zone)
{
if(StrContains(zone, ZONE_TRIGGER, false) == -1)
return;

InsideZone[client] = true;
}

public Zone_OnClientLeave(int client, char[] zone)
{
if (StrContains(zone, ZONE_TRIGGER, false) == -1)
return;

InsideZone[client] = false;
}


Now, if the attacker and he victim is inside the zone, no damage will be dealt. Otherwise, damage will be done.

Don't forget to donate if you enjoy my work :3 !

shanapu
06-27-2016, 19:00
I'll drop the code here.

i just have to say:
Big Thanks in name of sourcemod community for all your good/free work/help!
:bacon!::bacon!::bacon!:

Arkarr
06-28-2016, 02:45
i just have to say:
Big Thanks in name of sourcemod community for all your good/free work/help!
:bacon!::bacon!::bacon!:
As long as I take fun doing it... Anyway, thanks :D !