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

!fslay - Future Slay


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Capt.Underpants Paul
Member
Join Date: Mar 2013
Old 10-15-2014 , 06:50   !fslay - Future Slay
Reply With Quote #1

Basically, someone asked me for a script that they can go !fslay <name> and it auto slays them the next round.

heres what I've got, and I'm a bit confuesed. Any help would be appreciated

Code:
#include <sourcemod>
#include <sdktools>

new fslay_players;
 
public Plugin:myinfo =
{
	name = "Future Slay",
	author = "{Capt. Underpants} Paul",
	description = "Future Slay someone",
	version = "1.0.0.0",
	url = "http://www.mr-community.com/"
}
 
public OnPluginStart()
{
	RegAdminCmd("sm_fslay", Command_FSlay, ADMFLAG_SLAY);
	HookEvent("check_fslay",Event_RoundStart);
	
	fslay_players = CreateArray(32);
}

public Action:Command_FSlay(client,args)
{
	if (!args)
	{
		ReplyToCommand(client,"[SM] Usage: sm_fslay <target>");
		return Plugin_Handled;
	}
	decl String:pattern[32];
	GetCmdArg(1,pattern,sizeof(pattern));
	 
	new cl = FindTarget(client,pattern);
	 
	if (cl != -1)
		PushArrayString(fslay_players, cl);
	else
		ReplyToCommand(client,"%t","No target");
	 
	return Plugin_Handled; 
}

public Action:Event_RoundStart(Handle:event, const String:name[], bool:dontBroadcast)
{
	if (GetArraySize(fslay_players)>1)
	{
		for(new i=0; i<GetArraySize(fslay_players); i++; )
		{
			if (IsClientInGame(fslay_players[i]))
			{
				FSlayPlayer(fslay_players[i]);
			}
		}
		return Plugin_Continue;
	}
}

FSlayPlayer(target)
{
	// strip their weapons so they cannot gunplant after death
	new wepIdx;
	for (new i; i < 4; i++)
	{
		if ((wepIdx = GetPlayerWeaponSlot(target, i)) != -1)
		{
			RemovePlayerItem(target, wepIdx);
			AcceptEntityInput(wepIdx, "Kill");
		}
	}
	ForcePlayerSuicide(target);
}

}

Last edited by Capt.Underpants Paul; 10-15-2014 at 07:10. Reason: Updated Code
Capt.Underpants Paul is offline
LambdaLambda
AlliedModders Donor
Join Date: Oct 2010
Location: London
Old 10-15-2014 , 06:58   Re: !fslay - Future Slay
Reply With Quote #2

I haven't check your code, but I noticed so you'are trying to create global variable in function. Which isn't global anymore. You can change the parameter of global variables inside of them, but global variables are variables declared outside of any function. So you want to move

PHP Code:
new fslay_players
out of OnPluginStart(). E.g. just under your includes.
LambdaLambda is offline
Capt.Underpants Paul
Member
Join Date: Mar 2013
Old 10-15-2014 , 07:04   Re: !fslay - Future Slay
Reply With Quote #3

Quote:
Originally Posted by LambdaLambda View Post
I haven't check your code, but I noticed so you'are trying to create global variable in function. Which isn't global anymore. You can change the parameter of global variables inside of them, but global variables are variables declared outside of any function. So you want to move

PHP Code:
new fslay_players
out of OnPluginStart(). E.g. just under your includes.


Thanks

Error Messages at current standing:

Quote:
/groups/sourcemod/upload_tmp/textYr9zl0.sp(20) : warning 213: tag mismatch
/groups/sourcemod/upload_tmp/textYr9zl0.sp(36) : warning 213: tag mismatch
/groups/sourcemod/upload_tmp/textYr9zl0.sp(36) : error 035: argument type mismatch (argument 2)
/groups/sourcemod/upload_tmp/textYr9zl0.sp(47) : warning 213: tag mismatch
/groups/sourcemod/upload_tmp/textYr9zl0.sp(47) : error 001: expected token: ")", but found ";"
/groups/sourcemod/upload_tmp/textYr9zl0.sp(47) : error 036: empty statement
/groups/sourcemod/upload_tmp/textYr9zl0.sp(47) : error 029: invalid expression, assumed zero
/groups/sourcemod/upload_tmp/textYr9zl0.sp(47) : fatal error 127: too many error messages on one line
Guess I get some debugging to do


Edit: Just realised I have both fslay_player and fslay_players. all occurrences are now at fslay_players

Last edited by Capt.Underpants Paul; 10-15-2014 at 07:09. Reason: Edit Note added.
Capt.Underpants Paul is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 10-15-2014 , 08:41   Re: !fslay - Future Slay
Reply With Quote #4

fslay_players should be a Handle, not an Integer.
I would recommend saving yourself the hassle and change it to an array:
new fslay_players[MAXPLAYERS+1];

You don't even hook round_start as your round_start event, how did you think it would work with out a proper hook? :p

i made some edits, didn't try em out though:
Spoiler

Last edited by Mitchell; 10-15-2014 at 09:00.
Mitchell 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 09:32.


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