A warning (Rep+)
#1

pawn Код:
public OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid) {
    if(pTazer[playerid] == 1 && GetPlayerState(playerid) == PLAYER_STATE_ONFOOT && weaponid == 23 && amount > 10)
    {
        if(TazerTimeout[playerid] > 0) return true;
        if(PlayerCuffed[damagedid] == 0 && GetPlayerState(damagedid) == PLAYER_STATE_ONFOOT && (GetPlayerVirtualWorld(playerid) == GetPlayerVirtualWorld(damagedid))) {
            new
                Float:X,
                Float:Y,
                Float:Z,
                string[128];
            GetPlayerPos(playerid, X, Y, Z);

            if(!IsPlayerInRangeOfPoint(damagedid, 18.5, X, Y, Z))
                return SendClientMessage(playerid, COLOR_GRAD2, "Your tazer can't reach that far!");

            if(AdminDuty[damagedid] == 1 && GetPVarInt(damagedid, "AdminUndercover") == 0)
                return SendClientMessage(playerid, COLOR_GRAD2, "Admins can't be tazed!");

            if(GetPVarInt(damagedid, "Injured") == 1)
                return SendClientMessage(playerid, COLOR_GREY, "You can't taze injured people.");

            if(GetPlayerWeapon(damagedid) != 0 && !IsACop(damagedid)) {
                format(string, sizeof(string), "{AA3333}AdmWarning:{FFFF00} %s (ID %d) has possibly just rush tazed %s (ID %d).", GetPlayerNameEx(playerid), playerid, GetPlayerNameEx(damagedid), damagedid);
                ABroadCast(COLOR_YELLOW, string, 1);
            }

            format(string, sizeof(string), "* %s fires their tazer at %s, stunning them.", GetPlayerNameEx(playerid), GetPlayerNameEx(damagedid));
            ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
            GameTextForPlayer(damagedid, "~r~Tazed", 3500, 3);
            TogglePlayerControllable(damagedid, 0);
            ApplyAnimation(damagedid,"CRACK","crckdeth2",4.1,0,1,1,1,1,1);
            GetPlayerPos(damagedid, X, Y, Z);
            PlayerPlaySound(damagedid, 1085, X, Y, Z);
            PlayerPlaySound(playerid, 1085, X, Y, Z);
            PlayerCuffed[damagedid] = 1;
            SetPVarInt(damagedid, "PlayerCuffed", 1);
            PlayerCuffedTime[damagedid] = 16;
            SetPVarInt(damagedid, "IsFrozen", 1);
            TazerTimeout[playerid] = 4;
            SetTimerEx("TazerTimer",1000,false,"d",playerid);
            GameTextForPlayer(playerid, "~n~~n~~n~~n~~n~~n~~n~~n~~r~Tazer reloading... ~w~5", 1500,3);
            return true;
        }
    }
    if(pBeanBag[playerid] == 1 && GetPlayerState(playerid) == PLAYER_STATE_ONFOOT && weaponid == 25 && amount > 10)
    {
        new Float:currenthp;
        GetPlayerHealth(damagedid, currenthp);

        if((currenthp + amount) >= 100.0) SetPlayerHealth(damagedid, 100.0); else SetPlayerHealth(damagedid, (currenthp + amount));

        if(BeanBagTimeout[playerid] > 0) return true;
        if(PlayerCuffed[damagedid] == 0 && GetPlayerState(damagedid) == PLAYER_STATE_ONFOOT && (GetPlayerVirtualWorld(playerid) == GetPlayerVirtualWorld(damagedid))) {
            new
                Float:X,
                Float:Y,
                Float:Z,
                string[128];
            GetPlayerPos(playerid, X, Y, Z);

            if(!IsPlayerInRangeOfPoint(damagedid, 18.5, X, Y, Z))
                return SendClientMessage(playerid, COLOR_GRAD2, "Your bean bag shotgun can't reach that far!");

            if(AdminDuty[damagedid] == 1 && GetPVarInt(damagedid, "AdminUndercover") == 0)
                return SendClientMessage(playerid, COLOR_GRAD2, "Admins can't be bean bagged!");

            if(GetPVarInt(damagedid, "Injured") == 1)
                return SendClientMessage(playerid, COLOR_GREY, "You can't bean bag injured people.");

            if(GetPlayerWeapon(damagedid) != 0 && !IsACop(damagedid)) {
                format(string, sizeof(string), "{AA3333}AdmWarning:{FFFF00} %s (ID %d) has possibly just rush bean bagged %s (ID %d).", GetPlayerNameEx(playerid), playerid, GetPlayerNameEx(damagedid), damagedid);
                ABroadCast(COLOR_YELLOW, string, 1);
            }

                // Cuffed bitch.
                TogglePlayerControllable(damagedid, 0);
                PlayerCuffed[damagedid] = 1;
                SetPVarInt(damagedid, "PlayerCuffed", 1);
                PlayerCuffedTime[damagedid] = 16;
            }
            return true;
        }
} //Here is line 52635
PHP код:
C:\Users\TEST\Downloads\LYL11 (3).pwn(52635) : warning 209: function "OnPlayerGiveDamage" should return a value
Pawn compiler 3.2.3664              Copyright 
(c1997-2006ITB CompuPhase
1 Warning

How to fix it?
Reply
#2

pawn Код:
}
   return 1;
} //Here is line 52635
Try this.
Reply
#3

PHP код:
            }
            return 
true;
        }
//Here is line 52635 
PHP код:
            }
            return 
true;
        }
        return 
true;
//Here is line 52635 
Reply
#4

Quote:
Originally Posted by ProjectMan
Посмотреть сообщение
PHP код:
            }
            return 
true;
        }
//Here is line 52635 
PHP код:
            }
            return 
true;
        }
        return 
true;
//Here is line 52635 
Thanks for your help.
Reply
#5

To further explain this warning, AFAIK every single callback in SA:MP needs a return function, this is basically used to tell the server "everything went ok" or "something went wrong", or just to have more control.
"return 1" in this case tells the server that the callback was done correctly. If, for example, you return 1 in OnPlayerUpdate, everything goes as planned, but if you return 0 in it, the update will be cancelled, making the player "desynced".

OFF:Also, in case you didn't know, you need to have 50 posts before your reputation points actually matter. When you give reputation when your post count is under 50, it gives a "neutral" reputation point which will only become active once you hit 50 posts. So basically, you aren't giving any rep to the people who help you.
Reply
#6

Quote:
Originally Posted by [FSaF]Jarno
Посмотреть сообщение
To further explain this warning, AFAIK every single callback in SA:MP needs a return function, this is basically used to tell the server "everything went ok" or "something went wrong", or just to have more control.
"return 1" in this case tells the server that the callback was done correctly. If, for example, you return 1 in OnPlayerUpdate, everything goes as planned, but if you return 0 in it, the update will be cancelled, making the player "desynced".

OFF:Also, in case you didn't know, you need to have 50 posts before your reputation points actually matter. When you give reputation when your post count is under 50, it gives a "neutral" reputation point which will only become active once you hit 50 posts. So basically, you aren't giving any rep to the people who help you.
Thanks for your info.

I gave someone rep, and it's positive not neutral.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)