SA-MP Forums Archive
Taser system - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Taser system (/showthread.php?tid=401774)



Taser system - fury14 - 24.12.2012

Hi, i have a problem with a taser system... When i type /tazeron, taser object appears in right hand, and when i am changing weapons, object is still there... Now, i want when other weapon is picked that taser object disappear... Here is the video if you don't understand:

http://www.youtube.com/watch?v=V74ae...ature=*********


Re: Taser system - LarzI - 24.12.2012

You want the tazer to go back to the belt or where ever it's placed in the beginning of the video? In that case, please show us your AttachObjectToPlayer code relevant to the tazer-object


Re: Taser system - Ballu Miaa - 24.12.2012

Download this .inc and include it || https://sampforum.blast.hk/showthread.php?tid=59771

Under OnPlayerWeaponChange!

When you get weapon change! Player weapon != fist. Then RemovePlayerAttachedObject!


Re: Taser system - fury14 - 24.12.2012

Код:
new string[256];
	    		new sendername[MAX_PLAYER_NAME];
				GetPlayerName(playerid, sendername, sizeof(sendername));
			    TazerAcceso[playerid] = 1;
			    SetPlayerAttachedObject(playerid, 0, 18642, 6, 0.06, 0.01, 0.08, 180.0, 0.0, 0.0);
			    SendClientMessage(playerid,WHITE,"Vas tazer je sada ukljucen, da ga iskljucite, pisite /tazeroff.");
			    SendClientMessage(playerid,YELLOW,"*Da koristite tazer morate osobu udariti tazerom (sakama).");
			    format(string, sizeof(string), "* %s vadi elektro-soker.", sendername);
				ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
Ballu Miaa, can you insert that code in my command?


Re: Taser system - Ballu Miaa - 24.12.2012

This might help. This is an untested code mate. Try it!
pawn Код:
public OnPlayerUpdate(playerid)
{
      if(GetPlayerWeapon(playerid) != 0)
      {
             if(TazerAcceso[playerid] == 1)
             {
                 if(IsPlayerAttachedObjectSlotUsed(playerid, 7)) RemovePlayerAttachedObject(playerid, 7);
             }
      }
     return 1;
}



Re: Taser system - fury14 - 24.12.2012

No, it doesn't work Ballu Mia, Taser still appears :S


Re: Taser system - fury14 - 24.12.2012

Here is my /tazeron and /tazeroff command... And onplayerupdate public...

Код:
if (strcmp("/tazeron", cmdtext, true, 8) == 0)
	{
	    if(PlayerInfo[playerid][pLeader] == 1 || PlayerInfo[playerid][pMember] == 1 || PlayerInfo[playerid][pLeader] == 2 || PlayerInfo[playerid][pMember] == 2 || PlayerInfo[playerid][pLeader] == 3 || PlayerInfo[playerid][pMember] == 3)
	    {
	        if(OnDuty[playerid] != 1 && PlayerInfo[playerid][pMember] == 2 || OnDuty[playerid] == 0 && PlayerInfo[playerid][pLeader] == 2 || OnDuty[playerid] == 0 && PlayerInfo[playerid][pMember] == 1 || OnDuty[playerid] == 0 && PlayerInfo[playerid][pLeader] == 1 || OnDuty[playerid] == 0 && PlayerInfo[playerid][pMember] == 3 || OnDuty[playerid] == 0 && PlayerInfo[playerid][pLeader] == 3)
			{
   				SendClientMessage(playerid, COLOR_RED, "(Greska!) {C4C4C4}Niste na duznosti!");
			    return 1;
			}
			else if(OnDuty[playerid] != 0 && PlayerInfo[playerid][pMember] == 2 || OnDuty[playerid] == 1 && PlayerInfo[playerid][pLeader] == 2 || OnDuty[playerid] == 1 && PlayerInfo[playerid][pMember] == 1 || OnDuty[playerid] == 1 && PlayerInfo[playerid][pLeader] == 1 || OnDuty[playerid] == 1 && PlayerInfo[playerid][pMember] == 3 || OnDuty[playerid] == 1 && PlayerInfo[playerid][pLeader] == 3)
			{
			    if(TazerAcceso[playerid] == 1)
				{
				    SendClientMessage(playerid,COLOR_RED,"(Greska!) {C4C4C4}Vas tazer je vec ukljucen!");
				    return 1;
			    }
			    new string[256];
	    		new sendername[MAX_PLAYER_NAME];
				GetPlayerName(playerid, sendername, sizeof(sendername));
			    TazerAcceso[playerid] = 1;
			    SetPlayerAttachedObject(playerid, 7, 18642, 6, 0.06, 0.01, 0.08, 180.0, 0.0, 0.0);
			    SendClientMessage(playerid,WHITE,"*Vas tazer je sada ukljucen, da ga iskljucite, pisite /tazeroff.");
			    SendClientMessage(playerid,YELLOW,"**Da koristite tazer morate osobu udariti tazerom (sakama).");
			    format(string, sizeof(string), "* %s vadi elektro-soker.", sendername);
				ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
    		}
    	}
	    else return SendClientMessage(playerid, COLOR_RED,"(Greska!) {C4C4C4}Vi niste sluzbenik zakona te ne mozete koristiti tazer.");
		return 1;
	}
Код:
if (strcmp("/tazeroff", cmdtext, true, 9) == 0)
	{
		if(PlayerInfo[playerid][pLeader] == 1 || PlayerInfo[playerid][pMember] == 1 || PlayerInfo[playerid][pLeader] == 2 || PlayerInfo[playerid][pMember] == 2 || PlayerInfo[playerid][pLeader] == 3 || PlayerInfo[playerid][pMember] == 3)
	    {
	        if(OnDuty[playerid] != 1 && PlayerInfo[playerid][pMember] == 2 || OnDuty[playerid] == 0 && PlayerInfo[playerid][pLeader] == 2 || OnDuty[playerid] == 0 && PlayerInfo[playerid][pMember] == 1 || OnDuty[playerid] == 0 && PlayerInfo[playerid][pLeader] == 1 || OnDuty[playerid] == 0 && PlayerInfo[playerid][pMember] == 3 || OnDuty[playerid] == 0 && PlayerInfo[playerid][pLeader] == 3)
			{
   				SendClientMessage(playerid, COLOR_RED, "(Greska!) {C4C4C4}Niste na duznosti!");
			    return 1;
			}
			else if(OnDuty[playerid] != 0 && PlayerInfo[playerid][pMember] == 2 || OnDuty[playerid] == 1 && PlayerInfo[playerid][pLeader] == 2 || OnDuty[playerid] == 1 && PlayerInfo[playerid][pMember] == 1 || OnDuty[playerid] == 1 && PlayerInfo[playerid][pLeader] == 1 || OnDuty[playerid] == 1 && PlayerInfo[playerid][pMember] == 3 || OnDuty[playerid] == 1 && PlayerInfo[playerid][pLeader] == 3)
			{
			    if(TazerAcceso[playerid] == 0)
				{
				    SendClientMessage(playerid,COLOR_RED,"(Greska!) {C4C4C4}Vas tazer je vec iskljucen!");
				    return 1;
			    }
			    new string[256];
	    		new sendername[MAX_PLAYER_NAME];
				GetPlayerName(playerid, sendername, sizeof(sendername));
			    TazerAcceso[playerid] = 0;
		        RemovePlayerAttachedObject(playerid, 7);
		        SetPlayerAttachedObject( playerid, 7, 18642, 7, -0.034659, -0.063828, -0.096531, 137.936645, 91.323410, 300.308929, 1.000000, 1.000000, 1.000000 ); // Taser1 - 2
			    SendClientMessage(playerid,-1,"{FFFFFF}Vas tazer je sada iskljucen, da ga ukljucite, pisite /tazeron.");
			    format(string, sizeof(string), "* %s sprema elektro-soker.", sendername);
				ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
    		}
    	}
	    else return SendClientMessage(playerid, COLOR_RED,"(Greska!) {C4C4C4}Vi niste sluzbenik zakona te ne mozete koristiti tazer.");
		return 1;
	}
And onplayerupdate:
Код:
public OnPlayerUpdate(playerid)
{
	if(TazerAcceso[playerid] == 1)
	{
		if(GetPlayerWeapon(playerid) == 0)
		{
		    SetPlayerAttachedObject(playerid, 7, 18642, 6, 0.06, 0.01, 0.08, 180.0, 0.0, 0.0); //Taser
		    return 1;
		}
		if(GetPlayerWeapon(playerid) != 0)
		{
		    RemovePlayerAttachedObject(playerid, 7); //This remove the taser
		    return 1;
		}
	}// AND ETC....



Re: Taser system - Ballu Miaa - 24.12.2012

I think that all should work! No problem right?


Re: Taser system - Lordzy - 24.12.2012

Try using this:
pawn Код:
public OnPlayerUpdate(playerid)
{
      if(GetPlayerWeapon(playerid) != 0)
      {
             if(TazerAcceso[playerid] == 1)
             {
                 if(IsPlayerAttachedObjectSlotUsed(playerid, 7)) return RemovePlayerAttachedObject(playerid, 7);
             }
      }
      if(GetPlayerWeapon(playerid) == 0)
      {
       if(TazerAcceso[playerid] == 1)
       {
        SetPlayerAttachedObject(playerid, 7, 18642, 6, 0.06, 0.01, 0.08, 180.0, 0.0, 0.0); //Taser
       }
      }
     return 1;
}
Not tested as I'm on mobile.


Re: Taser system - fury14 - 24.12.2012

I tried that but its still same like on the video :S