/tackle command ( SCCANF )
#1

Hello there,
I made myself a nice little /tackle command but..
I want it that players can only tackle if they are MOVING.
If they're standing still they CAN'T tackle..
I think I need to do it with OnPlayerKeyStateChange or something, but I'm not sure.
Can anyone help me out, please?

/tackle:

Код:
forward Tackle(playerid);
forward waitfortackle(playerid);

	//--------------------TACKLE-------------------------//
	dcmd_tackle(playerid, params[])
	{
	new
		id;
	if (sscanf(params, "u", id)) SendClientMessage(playerid, 0xFF0000AA, "Usage: /tackle [Playerid/Part of Playername]");
	else if (id == INVALID_PLAYER_ID) SendClientMessage(playerid, 0xFF0000AA, "Player not found");
	else if(Vantispam[playerid] == 0)
	{
	if(GetDistanceBetweenPlayers(playerid, id) < 3)
	{
	if (!IsPlayerInAnyVehicle(id))
	{
	if(ResultChance(40))//40 procent kans dat het fout gaat
 	{
	new string[48];
	new strings[48];
	new tacklename[MAX_PLAYERS];
	new tackledname[MAX_PLAYERS];
	GetPlayerName(playerid, tacklename, sizeof(tacklename));
	format(string, sizeof(string), "You have been tackled by %s!",tacklename);
	TogglePlayerControllable(id, false);
	SendClientMessage(id,0xAA3333AA,string);
	GetPlayerName(id, tackledname, sizeof(tackledname));
	format(strings, sizeof(strings), "You have tackled %s!",tackledname);
	SendClientMessage(playerid,0xAA3333AA,strings);
	SetTimerEx("Tackle", 3000, false, "u", id);
	ApplyAnimation(id,"CRACK","crckdeth2",4.0,0,0,0,1,1);
	Vantispam[playerid] = 1;
	SetTimerEx("waitfortackle", 60000, false, "i", playerid);
	}else{
	  SendClientMessage(id,0xAA3333AA,"It failed!");
	}
	}else{
	  SendClientMessage(id,0xAA3333AA,"You need to wait before tackle again!");
	}
	}
	}
	if(GetDistanceBetweenPlayers(playerid, id) > 3)
	{
	SendClientMessage(playerid,0xAA3333AA,"Player is to far away!");
	}
	if(IsPlayerInAnyVehicle(id))
	{
	SendClientMessage(playerid,0xAA3333AA,"You can't tackle somebody when he's in a car!");
	}
	return 1;
	}
	
public Tackle(playerid)
{
	TogglePlayerControllable(playerid, true);
	ClearAnimations(playerid);
	return 1;
}
public waitfortackle(playerid)
{
	Vantispam[playerid] = 0;
	return 1;
}
Reply
#2

You can use this, but im not sure if it will work as i had problems with GetPlayerVelocity.

pawn Код:
new Float:Velocity[3];
GetPlayerVelocity(playerid, Velocity[0], Velocity[1], Velocity[2]);
if(Velocity[0] == 0 && Velocity[1] == 0 && Velocity[2] == 0) return SendClientMessage(playerid, 0xFF000000, "You need to move to use that command");
Reply
#3

Quote:
Originally Posted by Dark_Kostas
You can use this, but im not sure if it will work as i had problems with GetPlayerVelocity.

pawn Код:
new Float:Velocity[3];
GetPlayerVelocity(playerid, Velocity[0], Velocity[1], Velocity[2]);
if(Velocity[0] == 0 && Velocity[1] == 0 && Velocity[2] == 0) return SendClientMessage(playerid, 0xFF000000, "You need to move to use that command");
Код:
C:\Samp0.3Server.win32\gamemodes\Tacke.pwn(262) : error 029: invalid expression, assumed zero
C:\Samp0.3Server.win32\gamemodes\Tacke.pwn(262) : warning 215: expression has no effect
C:\Samp0.3Server.win32\gamemodes\Tacke.pwn(262) : error 001: expected token: ";", but found "if"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Errors.
Reply
#4

Maybe someone else know how to do it?
I really need it..
Reply
#5

Dark Kostas, I edited your script so it compiled, but it has no effect at all..
Can somebody else PLEASE help me.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)