[FilterScript] [FS] Duel Filterscript
#1

Hi.

Some time ago when I scripted for littlewhitey's I made this duel script, I converted it into a FS today and am releasing it now.

Commands:

/duel <invite the given playerid to a duel>
/duelaccept <accept a duel invite>
/cduel <reset your duel invite, so you can invite someone else>

You will need to edit line 184 & 185, 201 & 202 to your own prefered duel positions (I suggest you make them face eachother), when /duelaccepted both players position get set and they get health & armour then a 10 seconds countdown with freeze and they can start dueling.

Download:

http://pawn.pastebin.com/f1653f215

(NO MIRRORS PLEASE)

Please report any bugs.

Reply
#2

Nice.
Reply
#3

goood
Reply
#4

wow..
i can use this.. can u send me an .amx with the duel positions of LWґs please i dont know ehy but i cant edit (10 errors on compilation)
tnx
Reply
#5

Quote:
Originally Posted by vga_yankee
wow..
i can use this.. can u send me an .amx with the duel positions of LWґs please i dont know ehy but i cant edit (10 errors on compilation)
tnx
Post your errors, so we can help you.
Reply
#6

this is the problem...
when i add this script to my server... i cant use my gamemode comands..
how can i fix this??
pd: my game mode are using the same format on cmds. than u script
Reply
#7

thnx sneaky :P
Reply
#8

Haha, awesome.
Reply
#9

Thanks
Reply
#10

can u resolve my problem?
Reply
#11

Nice.
Reply
#12

Quote:
Originally Posted by LifestealeR
Nice but gives 26 error's
Reply
#13

I hope someone can fix this issue:

Quote:
Originally Posted by cas126
When I start the duel filterscript the gamemode cmds didnt work.
why??
i didnt edit this script into my gamemode.
can some1 help me plz??
Using this FS makes other commands for GM not functional, so any updates or fixes? or must dcmd must turned into if (!strcmp ?

Code:
#include <a_samp>

/*

	Duel Filterscript (Ripped from LW_LVDM)
	Brought to you by [NB]Sneaky

	www.99BlaZed.com
	www.sneakyhost.net

	You will need to edit line 184,185,201,202

*/

#define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
#define SendError(%1,%2) SendClientMessage(%1,COLOR_RED,"ERROR: " %2)
#define SendUsage(%1,%2) SendClientMessage(%1,COLOR_WHITE,"USAGE: " %2)

#define COLOR_ORANGE 	0xFF8040FF
#define COLOR_YELLOW 	0xFFFF00AA
#define COLOR_RED 		0xFF0000AA
#define COLOR_WHITE 	0xFFFFFFAA


stock
	g_GotInvitedToDuel[MAX_PLAYERS],
	g_HasInvitedToDuel[MAX_PLAYERS],
	g_IsPlayerDueling[MAX_PLAYERS],
	g_DuelCountDown[MAX_PLAYERS],
	g_DuelTimer[MAX_PLAYERS],
	g_DuelInProgress,
	g_DuelingID1,
	g_DuelingID2;

public OnFilterScriptInit()
{
	print("\t============================================");
	print("\tDuel Filterscript (Ripped from LW_LVDM)");
	print("\tBy: Sneaky");
	print("\t-");
	print("\tLoaded");
	print("\t============================================");
	return 1;
}

public OnFilterScriptExit()
{
	print("\t============================================");
	print("\tDuel Filterscript (Ripped from LW_LVDM)");
	print("\tBy: Sneaky");
	print("\t-");
	print("\tLoaded");
	print("\t============================================");
	return 1;
}

public OnPlayerConnect(playerid)
{
	g_GotInvitedToDuel[playerid] = 0;
	g_HasInvitedToDuel[playerid] = 0;
	g_IsPlayerDueling[playerid] = 0;
	return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
	if(playerid == g_DuelingID1 || playerid == g_DuelingID2)
	{
	  g_DuelInProgress = 0;
	}
	return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
	dcmd(duel,4,cmdtext);
	dcmd(cduel,5,cmdtext);
	dcmd(duelaccept,10,cmdtext);
	return 1;
}

dcmd_cduel(playerid, params[])
{
	#pragma unused params

	if(g_HasInvitedToDuel[playerid] == 0)
		return SendError(playerid, "You did not invite anyone to a duel!");

	SendClientMessage(playerid, COLOR_YELLOW, "You have reset your duel invite, you can now use /duel [playerid] again.");
	g_HasInvitedToDuel[playerid] = 0;

	return 1;
}

dcmd_duelaccept(playerid, params[])
{
	if(params[0] == '\0' || !IsNumeric(params))
	  return SendUsage(playerid, "/duelaccept [playerid]");

	if(g_DuelInProgress == 1)
		return SendError(playerid, "Another duel is in progress at the moment, wait till that duel is finished!");

  new
		DuelID = strvalEx(params),
		pName[MAX_PLAYER_NAME],
		zName[MAX_PLAYER_NAME],
		tString[128];

  if(DuelID != g_GotInvitedToDuel[playerid])
  	return SendError(playerid, "That player did not invite you to a duel!");

	GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
	GetPlayerName(DuelID, zName, MAX_PLAYER_NAME);

 	format(tString, sizeof(tString), "You accepted the duel with %s (ID:%d), duel will start in 10 seconds..",zName,DuelID);
 	SendClientMessage(playerid, COLOR_YELLOW, tString);

 	format(tString, sizeof(tString), "%s (ID:%d), accepted the duel with you, duel will start in 10 seconds..",pName,playerid);
 	SendClientMessage(DuelID, COLOR_YELLOW, tString);

 	format(tString, sizeof(tString), "(News) Duel between %s and %s will start in 10 seconds",pName,zName);
 	SendClientMessageToAll(COLOR_ORANGE, tString);

 	InitializeDuel(playerid);
 	InitializeDuelEx( DuelID);

 	g_IsPlayerDueling[playerid] = 1;
 	g_IsPlayerDueling[DuelID] = 1;

 	g_DuelingID1 = playerid;
  g_DuelingID2 = DuelID;

	g_DuelInProgress = 1;

	return 1;
}

dcmd_duel(playerid, params[])
{
	if(params[0] == '\0' || !IsNumeric(params))
	  return SendUsage(playerid, "/duel [playerid]");

	if(g_HasInvitedToDuel[playerid] == 1)
		return SendError(playerid, "You already invited someone to a duel! (Type, /cduel to reset your invite)");

	new
		DuelID = strvalEx(params),
		pName[MAX_PLAYER_NAME],
		zName[MAX_PLAYER_NAME],
		tString[128];

	GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
	GetPlayerName(DuelID, zName, MAX_PLAYER_NAME);

	if (!IsPlayerConnected(DuelID))
	  return SendError(playerid, "Player is not connected.");

 	if(	g_HasInvitedToDuel[DuelID] == 1)
 		return SendError(playerid, "That player is already invited to a duel!");

	if(	DuelID == playerid)
 		return SendError(playerid, "You can not duel yourself!");

 	format(tString, sizeof(tString), "You invited %s (ID:%d) to a 1 on 1 duel, wait till %s accepts your invite.",zName, DuelID, zName);
 	SendClientMessage(playerid, COLOR_YELLOW, tString);

 	format(tString, sizeof(tString), "You got invited by %s (ID:%d) to a 1 on 1 duel, type /duelaccept [playerid] to accept and start the duel. ",pName, playerid);
 	SendClientMessage(DuelID, COLOR_YELLOW, tString);

 	g_GotInvitedToDuel[DuelID] = playerid;
	g_HasInvitedToDuel[playerid] = 1;

	return 1;
}

forward InitializeDuel(playerid);
public InitializeDuel(playerid)
{
  g_DuelTimer[playerid] = SetTimerEx("DuelCountDown", 1000, 1, "i", playerid);

	SetPlayerHealth(playerid, 100);
	SetPlayerArmour(playerid, 100);

	//SetPlayerPos(playerid, X, Y, Z); // da1
	//SetPlayerFacingAngle(playerid, A);
  SetCameraBehindPlayer(playerid);
  TogglePlayerControllable(playerid, 0);
  g_DuelCountDown[playerid] = 11;

	return 1;
}

forward InitializeDuelEx(playerid);
public InitializeDuelEx(playerid)
{
  g_DuelTimer[playerid] = SetTimerEx("DuelCountDown", 1000, 1, "i", playerid);

	SetPlayerHealth(playerid, 100);
	SetPlayerArmour(playerid, 100);

  //SetPlayerPos(playerid, X, Y, Z);
  //SetPlayerFacingAngle(playerid, A);
  SetCameraBehindPlayer(playerid);
  TogglePlayerControllable(playerid, 0);
  g_DuelCountDown[playerid] = 11;

	return 1;
}

forward DuelCountDown(playerid);
public DuelCountDown(playerid)
{
	new
		tString[128] ;

	g_DuelCountDown[playerid] --;

	PlayerPlaySound(playerid, 1057, 0.0, 0.0, 0.0);

	format(tString, sizeof(tString), "~w~%d", g_DuelCountDown[playerid]);
	GameTextForPlayer(playerid, tString, 900, 3);

  if(g_DuelCountDown[playerid] == 0)
  {
    KillTimer(g_DuelTimer[playerid]);
    TogglePlayerControllable(playerid, 1);
    GameTextForPlayer(playerid,"~g~GO GO GO", 900, 3);
    return 1;
  }

	return 1;
}

strvalEx(xxx[])
{
	if(strlen(xxx) > 9)
	return 0;
	return strval(xxx);
}

IsNumeric(const string[])
{
	for (new i = 0, j = strlen(string); i < j; i++)
	{
		if (string[i] > '9' || string[i] < '0') return false;
	}
	return true;
}

public OnPlayerDeath(playerid, killerid, reason)
{
	new
	 	sString[128],
	  	pName[MAX_PLAYER_NAME],
	  	zName[MAX_PLAYER_NAME],
	  	Float:Health,
	  	Float:Armor;

	if(g_IsPlayerDueling[playerid] == 1 && g_IsPlayerDueling[killerid] == 1)
	{
		GetPlayerHealth(killerid, Health);
	 	GetPlayerArmour(killerid, Armor);

		GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
	 	GetPlayerName(killerid, zName, MAX_PLAYER_NAME);

		if(Health > 90.0 && Armor > 90.0)
	 	{
	  	format(sString, sizeof(sString),"(News) %s has \"OWNED\" %s in the duel and has %.2f health and %.2f armor left!", zName,pName,Health,Armor);
	   	SendClientMessageToAll(COLOR_ORANGE, sString);

			g_GotInvitedToDuel[playerid] = 0;g_HasInvitedToDuel[playerid] = 0;g_IsPlayerDueling[playerid] = 0;
	  		g_GotInvitedToDuel[killerid] = 0;g_HasInvitedToDuel[killerid] = 0;g_IsPlayerDueling[killerid] = 0;
	   	g_DuelInProgress = 0;
			return 1;
	  	}
	  	else
	  	{
  		format(sString, sizeof(sString),"(News) %s has won the duel from %s and has %.2f health and %.2f armor left!", zName,pName,Health,Armor);
	    	SendClientMessageToAll(COLOR_ORANGE, sString);

			g_GotInvitedToDuel[playerid] = 0;g_HasInvitedToDuel[playerid] = 0;g_IsPlayerDueling[playerid] = 0;
	  		g_GotInvitedToDuel[killerid] = 0;g_HasInvitedToDuel[killerid] = 0;g_IsPlayerDueling[killerid] = 0;
			g_DuelInProgress = 0;
			return 1;
	  }
	}
	return 1;
}
Reply
#14

End of OnPlayerCommandText should be return 0; This way it can carry on processing commands form the GM or other scripts and it can also return a 'unknown command' message.
Reply
#15

Quote:
Originally Posted by [ĦŁ₣
ЉǾǖŦĦЗŁΛẄ ]
End of OnPlayerCommandText should be return 0; This way it can carry on processing commands form the GM or other scripts and it can also return a 'unknown command' message.
TY
Reply
#16

Quote:
Originally Posted by klavins

Which server ? :P :P
Reply
#17

BUG : when player enter the car its shows fuel but when he get out from car the fuel msg still on display its must hide .. fix it plz
Reply
#18

Nice I'll be using this
________
IOLITE VAPORIZER
Reply
#19

You do not have the fs without dcmd? I put it in my GM over this impossible
Reply
#20

Quote:
Originally Posted by [HLF]Southclaw
View Post
End of OnPlayerCommandText should be return 0; This way it can carry on processing commands form the GM or other scripts and it can also return a 'unknown command' message.
THANKS A LOT MAN! You're the best, I was fucking wondering how to fix it, and you fucked the prob in sec! YOU'RE the best!
+rep'ed
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)