User
Pass
2FA
 
 

[AMXX] Modificarea DMG-ul facut de o arma

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Freakz Forum Index -> Trash Bin -> CS 2006-2019 (Archived) -> Tutorials
Author Message2335
FarulNUMOARE
[Banned user]


Banned


Status: Offline
(since 06-09-2013 11:05)
Joined: 14 Aug 2013
Posts: 264, Topics: 37
Location: Constanta.

Reputation: -100.7
Votes: 10

 
Post Posted: 20-08-2013, 18:02:11 | Translate post to: ... (Click for more languages)

Descriere: Dupã cum scrie ºi în titlu, am sã vã arãt cum modificaþi corect dmg-ul fãcut de o armã/cuþit/grenadã. Folosind aceastã metodã nu o sã primiþi erori în logs iar plugin-ul va funcþiona corect.

Tutorial:

1. Pentru modificarea dmg-ul avem nevoie de modulul hamsandwich pe care trebuie sã-l includem astfel:
Code:
#include <  hamsandwich  >     


2. Adãugãm un nou define ºi anume:
Code:
#define IsPlayer(%0)    ( 1 <= %0 <= g_iMaxPlayers )


3. Acum trebuie sã declarãm g_iMaxPlayers, adãugãm:
Code:
new g_iMaxPlayers


Acum trecem la init (plugin_init).

1. Adãugãm în init urmãtoarea linie:
Code:
g_iMaxPlayers = get_maxplayers ( )


Aceastã linie înseamnã cã g_iMaxPlayers cautã numãrul maxim de jucãtori dupã server.
2. Tot în init adãugãm urmãtoarea funcþie ham:
Code:
RegisterHam ( Ham_TakeDamage, "player", "Player_TakeDamage" )


Ham_TakeDamage = funcþia care o cere modulul ham.
player = entitatea asupra cãruia se exercitã funcþia.
Player_TakeDamage = numele public-ului care acþioneazã.


Gata cu init-ul, mai urmeazã public-ul, codul dvs. trebuie sã arate aºa pânã acum:
Code:
/* Plugin generated by AMXX-Studio */

#include <  amxmodx  >
#include <  hamsandwich  >

#define PLUGIN "Modificare Damage"
#define VERSION "0.1"
#define AUTHOR "hadesownage"

#define IsPlayer(%0)    ( 1 <= %0 <= g_iMaxPlayers )

new g_iMaxPlayers;

public plugin_init ( ) {
   
    register_plugin ( PLUGIN, VERSION, AUTHOR );
   
    g_iMaxPlayers = get_maxplayers ( )
    RegisterHam ( Ham_TakeDamage, "player", "Player_TakeDamage" );
}
 


Crearea public-ului:

1. Creeam public-ul cu 4 param-uri ºi acelea fiind:

iVictim - index-ul victimei.
iInflictor - cel care atacã.
iAttacker - index-ul atacatorului.
Float:fDamage - damage-ul fãcut.

Începutul public-ului va arãta aºa:
Code:
public Player_TakeDamage ( iVictim, iInflictor, iAttacker, Float:fDamage ) {


2. Acum trebuie sã adãugãm urmãtoarea verificaþie:
Code:
if ( iInflictor == iAttacker && IsPlayer ( iAttacker ) ) {


Aceasta verificã iInflictor este una ºi aceeaºi cu atacatorul ºi dacã atacatorul este un jucãtor nu o entitate oarecare.

3. În aceastã verificare trebuie sã adãugãm modificarea damage-ului, adãugãm urmãtoarea linie:
Code:
SetHamParamFloat ( 4, fDamage * 2.0 );


2.0 - cu cât se multiplicã dmg-ul fãcut de jucãtor.
2.0 - dublu.
3.0 - triplu.
4.0, 4.2, 4.5, 5.0 - ºi tot aºa.

4. Dupã linia de sus adãugãm un return ca funcþia sã se opreascã:
Code:
return HAM_HANDLED;



5. Dupã asta închidem verificaþia ( if-ul ) cu } si adãugãm:
Code:
return HAM_IGNORED;


Asta a fost tot, codul dvs. trebuie sã arate astfel:

Code:
/* Plugin generated by AMXX-Studio */

#include <  amxmodx  >
#include <  hamsandwich  >

#define PLUGIN "Modificare Damage"
#define VERSION "0.1"
#define AUTHOR "hadesownage"

#define IsPlayer(%0)    ( 1 <= %0 <= g_iMaxPlayers )

new g_iMaxPlayers;

public plugin_init ( ) {
   
    register_plugin ( PLUGIN, VERSION, AUTHOR );
   
    g_iMaxPlayers = get_maxplayers ( )
    RegisterHam ( Ham_TakeDamage, "player", "Player_TakeDamage" );
}

public Player_TakeDamage ( iVictim, iInflictor, iAttacker, Float:fDamage ) {
   
    if ( iInflictor == iAttacker && IsPlayer ( iAttacker ) ) {
   
        SetHamParamFloat ( 4, fDamage * 2.0 );
        return HAM_HANDLED;
       
    }
   
    return HAM_IGNORED;
   
}





JB.FREAKZ.RO este numarul 1!
0 0
  
Back to top
View user's profile Send private message Yahoo! Messenger ID
*@1rsTyle*

[Maniac]



Status: Offline
(since 06-08-2018 22:02)
Joined: 09 Jun 2012
Posts: 1461, Topics: 81
Location: Romania

Reputation: 499.6
Votes: 37

     
Post Posted: 20-08-2013, 18:05:03 | Translate post to: ... (Click for more languages)

Bun tutorial felicitari!


0 0
  
Back to top
View user's profile Send private message Yahoo! Messenger ID
martorul

[Mentally Stable]



Status: Offline
(since 23-10-2013 15:02)
Joined: 10 Aug 2013
Posts: 14, Topics: 3
Location: Romania

Reputation: 32.6
Votes: 1

Post Posted: 11-10-2013, 22:33:30 | Translate post to: ... (Click for more languages)

putin ajutor la id alex_cristian_2009
0 0
  
Back to top
View user's profile Send private message
enzo_98
[Banned user]


Banned


Status: Offline
(since 08-11-2019 09:54)
Joined: 18 Sep 2011
Posts: 3687, Topics: 333
Location: Romania

Reputation: 65.6
Votes: 218

       
Post Posted: 11-10-2013, 23:31:05 | Translate post to: ... (Click for more languages)

Nice,gj !

 
Staff message (Happy =]]):
 
Citeste regulamentul, data viitoare warn.



Concurs, +rep
0 0
  
Back to top
View user's profile Send private message Yahoo! Messenger ID
Widely1999

[Mentally Stable]



Status: Offline
(since 26-12-2013 08:40)
Joined: 31 Aug 2013
Posts: 94, Topics: 13
Location: Botosani

Reputation: 62
Votes: 4

 
Post Posted: 18-10-2013, 16:09:21 | Translate post to: ... (Click for more languages)

Frumos tutorial , felicitari.
0 0
  
Back to top
View user's profile Send private message Yahoo! Messenger ID
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Freakz Forum Index -> Trash Bin -> CS 2006-2019 (Archived) -> Tutorials  


The time now is 23-04-2024, 11:05:52
Copyright info

Based on phpBB ro/com
B

 
 
 







I forgot my password


This message appears only once, so
like us now until it's too late ! :D
x