OnPlayerTakeDamage
#1

I want the script to change bullet damage by weapon and variable enabled,but it won't work.

pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
{
if(StrategyArmy == 1)
{
    new Float: health;
    GetPlayerHealth(playerid,health);
    switch(weaponid)
    {
        case 31: SetPlayerHealth(playerid,health-30);
        case 24: SetPlayerHealth(playerid,health-30);
        case 35: SetPlayerHealth(playerid,health-40);
    }
    if(StrategyArmy == 2)
    {
    new Float: health;
    GetPlayerHealth(playerid,health);
    switch(weaponid)
    {
        case 34: SetPlayerHealth(playerid,health-60);
        case 25: SetPlayerHealth(playerid,health-30);
        case 16: SetPlayerHealth(playerid,health-70);
    }
    if(StrategyTerror == 1)
    {
    new Float: health;
    GetPlayerHealth(playerid,health);
    switch(weaponid)
    {
        case 31: SetPlayerHealth(playerid,health-30);
        case 24: SetPlayerHealth(playerid,health-30);
        case 35: SetPlayerHealth(playerid,health-40);
    }
    if(StrategyTerror == 2)
    {
    new Float: health;
    GetPlayerHealth(playerid,health);
    switch(weaponid)
    {
        case 34: SetPlayerHealth(playerid,health-60);
        case 25: SetPlayerHealth(playerid,health-30);
        case 16: SetPlayerHealth(playerid,health-70);
    }
    if(issuerid != INVALID_PLAYER_ID && weaponid == 4)
    {
         //One shot to kill with knife
        SetPlayerHealth(playerid, 0.0);
   }
return 1;
}
Код:
C:\Users\Tamer\Desktop\pwn\AVT scripting\gamemodes\GameMode.pwn(7753) : warning 219: local variable "health" shadows a variable at a preceding level
C:\Users\Tamer\Desktop\pwn\AVT scripting\gamemodes\GameMode.pwn(7763) : warning 219: local variable "health" shadows a variable at a preceding level
C:\Users\Tamer\Desktop\pwn\AVT scripting\gamemodes\GameMode.pwn(7773) : warning 219: local variable "health" shadows a variable at a preceding level
C:\Users\Tamer\Desktop\pwn\AVT scripting\gamemodes\GameMode.pwn(7786) : warning 217: loose indentation
C:\Users\Tamer\Desktop\pwn\AVT scripting\gamemodes\GameMode.pwn(7805) : error 030: compound statement not closed at the end of file (started at line 7763)
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.
Reply
#2

Brackets fixed.

PHP код:
public OnPlayerTakeDamage(playeridissueridFloatamountweaponid)
{
if(
StrategyArmy == 1)
{
    new 
Floathealth;
    
GetPlayerHealth(playerid,health);
    switch(
weaponid)
    {
        case 
31SetPlayerHealth(playerid,health-30);
        case 
24SetPlayerHealth(playerid,health-30);
        case 
35SetPlayerHealth(playerid,health-40);
    }
}
    if(
StrategyArmy == 2)
    {
    new 
Floathealth;
    
GetPlayerHealth(playerid,health);
    switch(
weaponid)
    {
        case 
34SetPlayerHealth(playerid,health-60);
        case 
25SetPlayerHealth(playerid,health-30);
        case 
16SetPlayerHealth(playerid,health-70);
    }
    }
    if(
StrategyTerror == 1)
    {
    new 
Floathealth;
    
GetPlayerHealth(playerid,health);
    switch(
weaponid)
    {
        case 
31SetPlayerHealth(playerid,health-30);
        case 
24SetPlayerHealth(playerid,health-30);
        case 
35SetPlayerHealth(playerid,health-40);
    }
    }
    if(
StrategyTerror == 2)
    {
    new 
Floathealth;
    
GetPlayerHealth(playerid,health);
    switch(
weaponid)
    {
        case 
34SetPlayerHealth(playerid,health-60);
        case 
25SetPlayerHealth(playerid,health-30);
        case 
16SetPlayerHealth(playerid,health-70);
    }
    }
    if(
issuerid != INVALID_PLAYER_ID && weaponid == 4)
    {
         
//One shot to kill with knife
        
SetPlayerHealth(playerid0.0);
   }
return 
1;

Reply
#3

pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
{
    static
        Float: szHealth
    ;
   
    GetPlayerHealth(playerid,szHealth);
   
    if(StrategyArmy == 1)
    {
       
       
        switch(weaponid)
        {
            case 31: SetPlayerHealth(playerid,szHealth-30);
            case 24: SetPlayerHealth(playerid,szHealth-30);
            case 35: SetPlayerHealth(playerid,szHealth-40);
        }
    }
   
   
    if(StrategyArmy == 2)
    {
        switch(weaponid)
        {
            case 34: SetPlayerHealth(playerid,szHealth-60);
            case 25: SetPlayerHealth(playerid,szHealth-30);
            case 16: SetPlayerHealth(playerid,szHealth-70);
        }
     }

     if(StrategyTerror == 1)
     {
        switch(weaponid)
        {
            case 31: SetPlayerHealth(playerid,szHealth-30);
            case 24: SetPlayerHealth(playerid,szHealth-30);
            case 35: SetPlayerHealth(playerid,szHealth-40);
        }
    }
   
   
    if(StrategyTerror == 2)
    {
        switch(weaponid)
        {
            case 34: SetPlayerHealth(playerid,szHealth-60);
            case 25: SetPlayerHealth(playerid,szHealth-30);
            case 16: SetPlayerHealth(playerid,szHealth-70);
        }
    }
   
    if(issuerid != INVALID_PLAYER_ID && weaponid == 4)
    {
         //One shot to kill with knife
        SetPlayerHealth(playerid, 0.0);
    }
    return 1;
}
Try this.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)