/tazer help +++rep
#1

I have a bug, when a cop /tazer's to pull out his tazer he can only taze cops. And also when he tazes the cop that shot the tazer also gets tazed, plus it automatically says missed the shot.

Код:
if(strcmp(cmd, "/tazer", true) ==0 || strcmp(cmd, "/ta", true) ==0)
	{
	    if(IsACop(playerid) || PlayerInfo[playerid][pDuty] == 1)
	    {
	        new weapons[13][2];
			for (new i = 0; i < 13; i++)
			{
			    GetPlayerWeaponData(playerid, i, weapons[i][0], weapons[i][1]);
			}
	        
			if(Tazer[playerid] == 0)
			{
				if(PlayerInfo[playerid][pTazerBullets] != 0)
				{
				    new ammo = weapons[2][1];
					PreTazerAmmo[playerid] = ammo;
					SafeGivePlayerWeapon(playerid, 23, PlayerInfo[playerid][pTazerBullets]);
					Tazer[playerid] = 1;
					AttachWeaponCorrectly(playerid, 24);
					SetPlayerSkillLevel(playerid, WEAPONSKILL_PISTOL_SILENCED, 500);
	    			OnePlayAnim(playerid,"SWORD","sword_block",50.0,0,1,1,1,1);
					format(string, sizeof(string), "* %s hostlers his Desert Deagle and Unhostlers his Tazer.", sendername);
					ProxDetector(30.0, playerid, string, COLOR_CHAT1,COLOR_CHAT2,COLOR_CHAT3,COLOR_CHAT4,COLOR_CHAT5);
				}
				else
				{
				    SendClientMessage(playerid, COLOR_GREY,"* No charges in the tazer!");
				    return 1;
				}
			}
			else
			{
				new ammo = weapons[2][1];
				PlayerInfo[playerid][pTazerBullets] = ammo;
				SafeGivePlayerWeapon(playerid, 24, PreTazerAmmo[playerid]);
				AttachWeaponCorrectly(playerid, 23);
				Tazer[playerid] = 0;
				ClearAnimations(playerid);
				SetPlayerSkillLevel(playerid, WEAPONSKILL_PISTOL_SILENCED, PlayerInfo[playerid][pSilenSkill]);
				format(string, sizeof(string), "* %s hostlers his tazer and Unhostlers his Deagle.", sendername);
				ProxDetector(30.0, playerid, string, COLOR_CHAT1,COLOR_CHAT2,COLOR_CHAT3,COLOR_CHAT4,COLOR_CHAT5);
			}
		}
	    return 1;
	}
Код:
else if ( PRESSED(KEY_FIRE) )
    {
        if(IsACop(playerid) || GetPlayerWeapon(playerid) == 23 || Tazer[playerid] == 1)
        {
            new Float:X,Float:Y,Float:Z,Float:pX,Float:pY,Float:pZ;
            GetPlayerPos(playerid, pX,pY,pZ);
            for(new i=0; i < MAX_PLAYERS; i++)
			{
				if(IsPlayerConnected(i))
				{
				    if(IsPlayerInRangeOfPoint(i,60, pX,pY,pZ))
				    {
				        if(i != playerid)
				        {
					        GetPlayerPos(i, X,Y,Z);
					        new iname[MAX_PLAYER_NAME];
					        GetPlayerName(i, iname, sizeof(iname));
	            			if(IsPlayerAimingAt(playerid, X,Y,Z,1.5))
	            			{
	            			    GameTextForPlayer(i,"~r~BEING TAZED",9000,4);
	            			    GameTextForPlayer(playerid, "~b~USING THE TAZER",2000,4);
	            			    TogglePlayerControllable(i, 0);
	            			    TogglePlayerControllable(playerid, 0);
	            			    ApplyAnimation(i, "CRACK", "crckdeth2", 4.0, 1, 0, 0, 0, 0);
	            			    SetTimerEx("Unfreezeply",9000,0,"i",i);
	            			    ApplyAnimation(playerid,"ped", "ARRESTgun", 4.0, 0, 1, 1, 1, -1);
	            			    SetTimerEx("Unfreezeply",1500,0,"i",playerid);
	            			    format(string, sizeof(string),"* %s Aims his Tazer at %s and Shoots it",sendername,iname);
	            			}
	            			else return GameTextForPlayer(playerid, "~b~Missed the Shoot",3750,4);
						}
					}
				}
			}
		}
Reply
#2

Use OnPlayerGiveDamage
https://sampwiki.blast.hk/wiki/OnPlayerGiveDamage
playerid = cop
damageid = tazed man
weaponid = tazer id


Something like this:
pawn Код:
public OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid)
{
        if(IsACop(playerid) || GetPlayerWeapon(playerid) == 23 || Tazer[playerid] == 1)
        {
        new iname[MAX_PLAYER_NAME]
            GameTextForPlayer(damageid,"~r~BEING TAZED",9000,4);
            GameTextForPlayer(playerid, "~b~USING THE TAZER",2000,4);
            TogglePlayerControllable(damageid, 0);
            TogglePlayerControllable(playerid, 0);
            ApplyAnimation(damageid, "CRACK", "crckdeth2", 4.0, 1, 0, 0, 0, 0);
            SetTimerEx("Unfreezeply",9000,0,"i",damageid);
            ApplyAnimation(playerid,"ped", "ARRESTgun", 4.0, 0, 1, 1, 1, -1);
            SetTimerEx("Unfreezeply",1500,0,"i",playerid);
            format(string, sizeof(string),"* %s Aims his Tazer at %s and Shoots it",sendername,iname);
                //Send the message to near player
        }
        return 1;
}
Reply
#3

also
Код:
            for(new i=0; i < MAX_PLAYERS; i++)
			{
suggest you to use "GetMaxPlayers"
https://sampwiki.blast.hk/wiki/GetMaxPlayers
Reply
#4

Quote:
Originally Posted by Skillet`
Посмотреть сообщение
also
Код:
            for(new i=0; i < MAX_PLAYERS; i++)
			{
suggest you to use "GetMaxPlayers"
https://sampwiki.blast.hk/wiki/GetMaxPlayers
Why? There is no point using this. If OnPlayerTakeDamage is a function that is call when someone get shot, it will be only 1 player.
Reply
#5

Quote:
Originally Posted by lelemaster
Посмотреть сообщение
Why? There is no point using this. If OnPlayerTakeDamage is a function that is call when someone get shot, it will be only 1 player.
That wasn't my point,the point was that if you're using loop then use GetMaxPlayer instead of MAX_PLAYERS because MAX_PLAYERS is a definition,means it replaced with a number,which is 500.
what the point to loop 500 times if you have only 30 slots ? 470 useless loops.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)