Tazer by a weapon? -
acade - 25.02.2010
Hey,
is it possible to make a tazer command be used by a weapon instead of a command?
Well, I know its possible but how can it be done?
Thanks
Re: Tazer by a weapon? -
dice7 - 25.02.2010
pawn Код:
public OnPlayerKeyStateChange(playerid, oldkeys, newkeys)
{
if((newkeys & KEY_FIRE) && GetPlayerWeapon == some weapon id)
{
//tazer cmd
}
}
Re: Tazer by a weapon? -
acade - 25.02.2010
Thanks!
Re: Tazer by a weapon? -
acade - 25.02.2010
Error:
Код:
G:\Fusion RP Temp\gamemodes\v0.2.pwn(18968) : error 076: syntax error in the expression, or invalid function call
Line:
pawn Код:
if ((newkeys & KEY_FIRE) && GetPlayerWeapon == 24)
Re: Tazer by a weapon? -
dice7 - 25.02.2010
GetPlayerWeapon(playerid)
Re: Tazer by a weapon? -
acade - 25.02.2010
Yep stupid me, fixed it
Testing now.
Re: Tazer by a weapon? -
acade - 25.02.2010
Ok, I've copied my tazer command but now I can taze across the map.
Is their away to change this
pawn Код:
new suspect = GetClosestPlayer(playerid);
to the person who has been shot, not the nearest?
Thanks again.
This is my code:
Код:
if(newkeys & KEY_FIRE)
{
if(GetPlayerWeapon(playerid == 23))
{
new string[128];
new suspect = GetClosestPlayer(playerid);
format(string, sizeof(string), "Tazed by %s for 60 seconds.", GetPlayerNameEx(playerid));
SendClientMessage(suspect, COLOR_RED, string);
format(string, sizeof(string), "You tazed %s 60 seconds.", GetPlayerNameEx(suspect));
SendClientMessage(playerid, COLOR_WHITE, string);
TogglePlayerControllable(suspect, 0);
PlayerTazed[suspect] = 1;
SetTimerEx("UntazePlayer", 60000, false, "i", suspect);
PlayerPlayerActionMessage(playerid,suspect,15.0,"has just tazed");
}
return 1;
}
return 1;
I can get any weapon out and taze as well as anywhere across the map.
Re: Tazer by a weapon? -
dice7 - 25.02.2010
This would be kinda hard to realize because of the desync, but it looks something like this
pawn Код:
new
Float:health[MAX_PLAYERS],
shot[MAX_PLAYERS];
public OnPlayerSpawn(playerid)
{
GetPlayerHealth(playerid, health[playerid]);
return 1;
}
public OnPlayerUpdate(playerid)
{
new
Float:temp;
GetPlayerHealth(playerid, temp);
if(health[playerid] > temp)
{
OnPlayerLooseHealth(playerid, temp, health[playerid]);
GetPlayerHealth(playerid, health[playerid]);
}
return 1;
}
public OnPlayerKeyStateChange(playerid, oldkeys, newkeys)
{
if((newkeys & KEY_FIRE) && GetPlayerWeapon(playerid) == some weapon id)
{
shot[playerid] = 1;
SetTimerEx("ResetShot", 1500, 0, "d", playerid);
return 1;
}
}
OnPlayerLooseHealth(playerid, oldhealth, newhealth)
{
for(new id = 0; id < MAX_PLAYERS; id++)
{
if(shot[id] == 1)
{
new
Float:angle;
GetPlayerFacingAngle(id, angle);
if(IsPlayerFacingPlayer(id, playerid, 5.0))
{
//taze 'playerid'
return 1;
}
}
}
return 1;
}
forward ResetShot(playerid);
public ResetShot(playerid)
{
shot[playerid] = 0;
}
You can get IsPlayerFacingPlayer here
http://forum.sa-mp.com/index.php?topic=130630.0
Re: Tazer by a weapon? -
acade - 25.02.2010
Ok thanks,
For this part
pawn Код:
OnPlayerLooseHealth(playerid, oldhealth, newhealth)
{
for(new id = 0; id < MAX_PLAYERS; id++)
{
if(shot[id] == 1)
{
new
Float:angle;
GetPlayerFacingAngle(id, angle);
if(IsPlayerFacingPlayer(id, playerid, 5.0))
{
//taze 'playerid'
return 1;
}
}
}
return 1;
}
Do I add my taze code from above?
Re: Tazer by a weapon? -
acade - 25.02.2010
If shot a player with the tazer, using debug code under and where
is, I've added debug tags,
These haven't shown up for me or the player being shot.
pawn Код:
forward OnPlayerLooseHealth(playerid, oldhealth, newhealth);
public OnPlayerLooseHealth(playerid, oldhealth, newhealth)
{
for(new id = 0; id < MAX_PLAYERS; id++)
{
if(shot[id] == 1)
{
new
Float:angle;
GetPlayerFacingAngle(id, angle);
if(IsPlayerFacingPlayer(id, playerid, 5.0))
{
SendClientMessage(playerid, COLOR_WHITE, "[DEBUG] You shall be tazed");
SendClientMessage(id, COLOR_YELLOW, "[DEBUG] You shall be tazed");
return 1;
}
}
}
return 1;
}