Raised This Month: $51 Target: $400
 12% 

SoccerLR


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
applemes
Senior Member
Join Date: Mar 2013
Old 04-26-2013 , 16:44   SoccerLR
Reply With Quote #1

Hello, im tryign to make a soccer LR but idk how to teleport the CTS to one location and Ts to Other.
Here is my plugin ATM

Code:
include <sourcemod>
#include <sdktools>
#include <hosties>
#include <lastrequest>
#include <colors>

#pragma semicolon 1

#define PLUGIN_VERSION "1"

#define origin1 {-2764.626465, -1841.602417, 100.031311}

#define origin2 {-2761.957031, -211.189545, 100.031311}

// This global will store the index number for the new Last Request
new g_LREntryNum;

new String:g_sLR_Name[64];

new Handle:gH_Timer_GiveHealth = INVALID_HANDLE;
new Handle:gH_Timer_Countdown = INVALID_HANDLE;

new bool:bAllCountdownsCompleted = false;

enum theColors
{
	color_Red = 0,
	color_Green,
	color_Blue
};

public Plugin:myinfo =
{
	name = "Last Request: Soccer",
	author = "Dustin",
	description = "Soccer Lr",
	version = PLUGIN_VERSION,
	url = ""
};

public OnPluginStart()
{

}

public OnConfigsExecuted()
{
	static bool:bAddedSoccer = false;
	if (!bAddedSoccer)
	{
		g_LREntryNum = AddLastRequestToList(Soccer_Start, Soccer_Stop, g_sLR_Name);
		bAddedSoccer = true;
	}	
}

// The plugin should remove any LRs it loads when it's unloaded
public OnPluginEnd()
{
	RemoveLastRequestFromList(Soccer_Start, Soccer_Stop, g_sLR_Name);
}

public Soccer_Start(Handle:LR_Array, iIndexInArray)
{
	new This_LR_Type = GetArrayCell(LR_Array, iIndexInArray, _:Block_LRType);
	if (This_LR_Type == g_LREntryNum)
	{		
		new LR_Player_Prisoner = GetArrayCell(LR_Array, iIndexInArray, _:Block_Prisoner);
		new LR_Player_Guard = GetArrayCell(LR_Array, iIndexInArray, _:Block_Guard);
		
		// check datapack value
		new LR_Pack_Value = GetArrayCell(LR_Array, iIndexInArray, _:Block_Global1);	
		switch (LR_Pack_Value)
		{
			case -1:
			{
				PrintToServer("no info included");
			}
		}
		
		SetEntityHealth(LR_Player_Prisoner, 100);
		SetEntityHealth(LR_Player_Guard, 100);
		
		StripAllWeapons(LR_Player_Prisoner);
		StripAllWeapons(LR_Player_Guard);
		
		// Store a countdown timer variable - we'll use 3 seconds
		SetArrayCell(LR_Array, iIndexInArray, 3, _:Block_Global1);
		
		if (gH_Timer_Countdown == INVALID_HANDLE)
		{
			gH_Timer_Countdown = CreateTimer(1.0, Timer_Countdown, _, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
		}
		
		PrintToChatAll(CHAT_BANNER, "LR Soccer Start", LR_Player_Prisoner, LR_Player_Guard);
	}
}

public Soccer_Stop(This_LR_Type, LR_Player_Prisoner, LR_Player_Guard)
{
	if (This_LR_Type == g_LREntryNum)
	{
		if (IsClientInGame(LR_Player_Prisoner))
		{
			SetEntityGravity(LR_Player_Prisoner, 1.0);
			if (IsPlayerAlive(LR_Player_Prisoner))
			{
				SetEntityHealth(LR_Player_Prisoner, 100);
				GivePlayerItem(LR_Player_Prisoner, "weapon_knife");
				PrintToChatAll(CHAT_BANNER, "Soccer Win", LR_Player_Prisoner);
			}
		}
		if (IsClientInGame(LR_Player_Guard))
		{
			SetEntityGravity(LR_Player_Guard, 1.0);
			if (IsPlayerAlive(LR_Player_Guard))
			{
				SetEntityHealth(LR_Player_Guard, 100);
				GivePlayerItem(LR_Player_Guard, "weapon_knife");
				PrintToChatAll(CHAT_BANNER, "Soccer Win", LR_Player_Guard);
			}
		}
	}
}

public Action:Timer_Countdown(Handle:timer)
{
	new numberOfLRsActive = ProcessAllLastRequests(Soccer_Countdown, g_LREntryNum);
	if ((numberOfLRsActive <= 0) || bAllCountdownsCompleted)
	{
		gH_Timer_Countdown = INVALID_HANDLE;
		return Plugin_Stop;
	}
	return Plugin_Continue;
}

public Action:Timer_GiveHealth(Handle:timer)
{
	// Sort through all last requests
	new numberOfLRsActive = ProcessAllLastRequests(Soccer_Heal, g_LREntryNum);	
	if (numberOfLRsActive <= 0)
	{
		gH_Timer_GiveHealth = INVALID_HANDLE;
		return Plugin_Stop;
	}
	return Plugin_Continue;
}

public Soccer_Countdown(Handle:LR_Array, iIndexInArray)
{
	new LR_Player_Prisoner = GetArrayCell(LR_Array, iIndexInArray, _:Block_Prisoner);
	new LR_Player_Guard = GetArrayCell(LR_Array, iIndexInArray, _:Block_Guard);
	
	new countdown = GetArrayCell(LR_Array, iIndexInArray, _:Block_Global1);
	if (countdown > 0)
	{
		bAllCountdownsCompleted = false;
		PrintCenterText(LR_Player_Prisoner, "LR begins in %i...", countdown);
		PrintCenterText(LR_Player_Guard, "LR begins in %i...", countdown);
		SetArrayCell(LR_Array, iIndexInArray, --countdown, _:Block_Global1);		
	}
	else if (countdown == 0)
	{
		bAllCountdownsCompleted = true;
		SetArrayCell(LR_Array, iIndexInArray, --countdown, _:Block_Global1);	
		
		new PrisonerGun = GivePlayerItem(LR_Player_Prisoner, "weapon_knife");
		new GuardGun = GivePlayerItem(LR_Player_Guard, "weapon_knife");
		
		SetArrayCell(LR_Array, iIndexInArray, PrisonerGun, _:Block_PrisonerData);
		SetArrayCell(LR_Array, iIndexInArray, GuardGun, _:Block_GuardData);
		
		SetEntityRenderFx(PrisonerGun, RenderFx:RENDERFX_DISTORT);
		SetEntityRenderFx(GuardGun, RenderFx:RENDERFX_DISTORT);
		
		SetEntityRenderColor(PrisonerGun, 255, 0, 0, 255);
		SetEntityRenderColor(GuardGun, 255, 0, 0, 255);
		
		SetEntityGravity(LR_Player_Prisoner, 0.7);
		SetEntityGravity(LR_Player_Guard, 0.7);
		
		if (gH_Timer_GiveHealth == INVALID_HANDLE)
		{
			gH_Timer_GiveHealth = CreateTimer(2.0, Timer_GiveHealth, _, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
		}
	}
}

public Soccer_Heal(Handle:LR_Array, iIndexInArray)
{
	new Prisoner = GetArrayCell(LR_Array, iIndexInArray, _:Block_Prisoner);
	new Guard = GetArrayCell(LR_Array, iIndexInArray, _:Block_Guard);
	
	SetEntityHealth(Prisoner, GetClientHealth(Prisoner) + 10);
	SetEntityHealth(Guard, GetClientHealth(Guard) + 10);
	
	new PrisonerGun = GetArrayCell(LR_Array, iIndexInArray, _:Block_PrisonerData);
	new GuardGun = GetArrayCell(LR_Array, iIndexInArray, _:Block_GuardData);
	
	static randomColor = _:color_Red;
	
	switch (randomColor % 3)
	{
		case color_Red:
		{
			SetEntityRenderColor(PrisonerGun, 255, 0, 0, 255);
			SetEntityRenderColor(GuardGun, 255, 0, 0, 255);
		}
		case color_Green:
		{
			SetEntityRenderColor(PrisonerGun, 0, 255, 0, 255);
			SetEntityRenderColor(GuardGun, 0, 255, 0, 255);		
		}
		case color_Blue:
		{
			SetEntityRenderColor(PrisonerGun, 0, 0, 255, 255);
			SetEntityRenderColor(GuardGun, 0, 0, 255, 255);
		}
	}
	
	randomColor++;
}
Origin1 Being T and Origin2 being CT

Last edited by applemes; 04-26-2013 at 16:46.
applemes is offline
s.b.s
New Member
Join Date: Jan 2013
Old 04-27-2013 , 13:28   Re: SoccerLR
Reply With Quote #2

First, does this work?
and
Second, What map is this for?
s.b.s is offline
applemes
Senior Member
Join Date: Mar 2013
Old 04-27-2013 , 13:56   Re: SoccerLR
Reply With Quote #3

well, the lr doesnt have a name in !lr, it gives me weapon knife but doesn't teleport ct or t . Its for ba_jail_electric_razor_v6
applemes is offline
DorCoMaNdO
Senior Member
Join Date: Feb 2012
Old 04-28-2013 , 16:09   Re: SoccerLR
Reply With Quote #4

under "countdown == 0" (in Soccer_Countdown) add :
Code:
TeleportEntity( LR_Player_Prisoner, origin1, NULL_VECTOR, NULL_VECTOR );
TeleportEntity( LR_Player_Guard, origin2, NULL_VECTOR, NULL_VECTOR );
define origin1 and origin2 correctly :
Code:
new Float:origin1[3] = {-2764.626465, -1841.602417, 100.031311};
new Float:origin2[3] = {-2761.957031, -211.189545, 100.031311};
DorCoMaNdO is offline
applemes
Senior Member
Join Date: Mar 2013
Old 04-28-2013 , 21:52   Re: SoccerLR
Reply With Quote #5

That teleported the CT but not the T for some reason.

and it still has no name :/
applemes is offline
DorCoMaNdO
Senior Member
Join Date: Feb 2012
Old 04-30-2013 , 05:14   Re: SoccerLR
Reply With Quote #6

Quote:
Originally Posted by applemes View Post
That teleported the CT but not the T for some reason.

and it still has no name :/
For name add the following code at OnPluginStart :
Code:
g_sLR_Name = "Whatever"
Check your server error logs (sourcemod/logs, the latest file with "error" in the name) to see what is the problem with the teleport.
DorCoMaNdO is offline
applemes
Senior Member
Join Date: Mar 2013
Old 04-30-2013 , 16:25   Re: SoccerLR
Reply With Quote #7

Quote:
Originally Posted by DorCoMaNdO View Post
For name add the following code at OnPluginStart :
Code:
g_sLR_Name = "Whatever"
Check your server error logs (sourcemod/logs, the latest file with "error" in the name) to see what is the problem with the teleport.
"it saids g_sLR_Name is not defined.
applemes is offline
Eden.Campo
Member
Join Date: Mar 2013
Old 05-04-2013 , 14:00   Re: SoccerLR
Reply With Quote #8

Quote:
Originally Posted by applemes View Post
"it saids g_sLR_Name is not defined.
new String:g_sLR_Name[64];

public OnPluginStart()
{
...
g_sLR_Name = "SomeString";
}
Eden.Campo is offline
DorCoMaNdO
Senior Member
Join Date: Feb 2012
Old 05-06-2013 , 19:07   Re: SoccerLR
Reply With Quote #9

Quote:
Originally Posted by applemes View Post
"it saids g_sLR_Name is not defined.
At the code you gave in the first post, it was defined, if you removed it, thats the problem.
DorCoMaNdO is offline
Ponska
Junior Member
Join Date: May 2013
Old 05-06-2013 , 19:33   Re: SoccerLR
Reply With Quote #10

It would be better to create a plugin so that any map can have that LR, perhaps with commands to set the area Soccer
Ponska is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 04:06.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode