Jump to content

[ Tutorial ] Taser System


khain.dev

Recommended Posts

Salut! In acest tutorial o sa va invat cum sa faceti un sistem de taser pentru politie etc.


/* variabila */
new 
  taser[MAX_PLAYERS] /* avem nevoie de aceasta variabila pentru activare si dezactivare a tase-rului */
;

/* mergem in OnPlayerConnect */

public OnPlayerConnect(playerid) {
  
  /* atribuim player-ului la conectarea pe server taser dezactivat */
  taser[playerid] = 0; /* taser - variabila atrbuita la inceput | playerid - id jucator | 0 - raspunde ca functie neactiva */

  return 1;
}

/* Mergem in OnPlayerKeyStateChange */
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
	if(newkeys == KEY_YES) { /* activarea/dezactivarea are loc prin butonul Y | KEY_YES - Y */   
      new 
        weap, /* inregistram prin weap arma noastra ca taser */
        ammo; /* id arma */
      
	  /* functia ce verifica daca are jucatorul arma necesara */
      GetPlayerWeaponData(playerid,2,weap,ammo); /* playerid - id jucator | 2 - slot | weap - arma inregistrata ca taser | ammo - id arma */

      /* verificam daca player-ul are arma necesara, in cazul meu Deagle. */
      if(weap != 24) 
          return 
              SendClientMessage(playerid, -1, "Nu ai arma necesara pentru Taser."); 

      /* verificam daca taser-ul este activat */
      if(taser[playerid]) { 
        taser[playerid] = 0; 
        return 
          SendClientMessage(playerid, -1, "Tase-rul nu este activat."); 
      } 
      else {  /* activam taser-ul */
          taser[playerid] = 1; 
          return 
              SendClientMessage(playerid,-1,"Taser-ul a fost activat."); 
      }
    }
	return 1;
}

/* mergem in OnPlayerWeaponShot */
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{

  if(hittype == 1 && weaponid == 24 && taser[playerid] == 1) return staser(playerid,hitid);
  //hittype - tipul de foc, in cazul nostru se atribuie la playerl [ 1 - player ]
  //weaponid - id arma
  //taser[playerid] - deja stiti ( atribuire 1 - stock-ul pe care il avem, i se atribuie armei introduse de noi la variabila care inregistreaza statusul   taserului
  return 1;
}

/* megem in orice loc al GM-ului */
stock staser(playerid, suspectid) { 
  
  SetPlayerSpecialAction(suspectid,SPECIAL_ACTION_HANDSUP); // atribuim animatia care dupa idee il electrocuteaza 
  ShowPlayerDialog(playerid, 0, DIALOG_STYLE_MSGBOX, "{9ACD32}Taser", "\n\nAi fost electrocutat cu o arma speciala Taser ( Deagle )\n\n", "x", ""); // informam player-ul ca a fost electrocutat.
  return 0; 
}


*voi puteti adauga verificarile necesare

 

Edited by Khain Developer
  • Upvote 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more details you can also review our Terms of Use and Privacy Policy.