SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 09/08/2017, 03:04 AM   #11
asri
Big Clucker
 
Join Date: May 2017
Location: Malaysia
Posts: 114
Reputation: 1
Default Re: bug

the log show this after update the code.but when go dm,the room is blank when die in dm mode the print not show.

Quote:
[10:29:39] OnPlayerDeath: playerid: 0, killerid; 65535, reason: 7
[10:32:45] OnPlayerDeath: playerid: 0, killerid; 65535, reason: 7
[10:33:12] OnPlayerDeath: playerid: 0, killerid; 65535, reason: 3
[10:33:47] OnPlayerDeath: playerid: 0, killerid; 65535, reason: %
[10:35:57] OnPlayerDeath: playerid: 0, killerid; 65535, reason: %
the code
PHP Code:
public OnPlayerDeath(PIDkilleridreason)
{
    if(
killerid != INVALID_PLAYER_ID)
    {

            if(
killerid != INVALID_PLAYER_ID)
            {
                
SetPlayerScore(killeridGetPlayerScore(killerid)+1);
                
GivePlayerMoney(killerid4000);
                
scm(killerid, -1"Congratulation!You have gained 4000$ and +2 score.");
                
SetPlayerScore(PIDGetPlayerScore(PID) -1);
                
GivePlayerMoney(PID, -2000);
                
scm(PID, -1"You lost 2000$ because you noob.");
            }

            if(
god_mode[PID] == 1)
            {
                        
god_mode[PID] = 0;
                        return 
1;
            }

            if(
killerid != INVALID_PLAYER_ID)
            {
             if(
InDM[PID] == true)
             {
               if(
anakko[PID] == 1)
               {
                    
anakko[PID] = 0;
                     if(
makko[PID] != INVALID_PLAYER_ID)
                    
TogglePlayerSpectating(PID1);
                    
PlayerSpectatePlayer(PIDkillerid);
                    
SendClientMessage(PIDSKYBLUE    "You have been killed, you are now spectating your killer.");
                    
SetTimerEx("EndDeathCam"10000false"i"playerid);
               }
               else
               {
                    
TogglePlayerSpectating(PID0);
                    
killstreak(PIDkillerid);
                    
DestroyDynamic3DTextLabel(wanted[killerid]);
                    return 
1;
               }
             }
            }

            
PlayerTextDrawHide(PID,Textdraw0);
            
PlayerTextDrawHide(PID,Textdraw1);
            
PlayerTextDrawHide(PID,Textdraw2);
            
PlayerTextDrawHide(PID,Textdraw3);
            
            
GameTextForPlayer(playerid,"~r~wasted",20004);
            
gPlayerHasCitySelected[PID] = 0;
            
anakko[PID] = 1;
            
ClearAnimations(PID);
            
rBit2_Set(UnderWaterPIDfalse);
            
printf("OnPlayerDeath: playerid: %d, killerid; %d, reason: %s"playeridkilleridreason);
            return 
1;
    }
    return 
1;

in dm


when leave dm.the player spawn but he fall first and then he spawn




asri is offline   Reply With Quote
Old 11/08/2017, 01:54 AM   #12
asri
Big Clucker
 
Join Date: May 2017
Location: Malaysia
Posts: 114
Reputation: 1
Default Re: bug

help
asri is offline   Reply With Quote
Old 11/08/2017, 04:40 AM   #13
asri
Big Clucker
 
Join Date: May 2017
Location: Malaysia
Posts: 114
Reputation: 1
Default Re: bug

help
asri is offline   Reply With Quote
Old 11/08/2017, 10:04 AM   #14
asri
Big Clucker
 
Join Date: May 2017
Location: Malaysia
Posts: 114
Reputation: 1
Default Re: bug

anyone
asri is offline   Reply With Quote
Old 11/08/2017, 10:52 AM   #15
Arthur Kane
Gangsta
 
Join Date: Sep 2012
Posts: 659
Reputation: 29
Default Re: bug

What's the current problem? Your post is a mess.
Arthur Kane is offline   Reply With Quote
Old 11/08/2017, 11:19 AM   #16
asri
Big Clucker
 
Join Date: May 2017
Location: Malaysia
Posts: 114
Reputation: 1
Default Re: bug

before i add the bud include the script is ok. Then, the player is death the gametext not show and log show this

Quote:
[18:18:17] BUD::MultiGet returned:
money: 7450
kills: 0
deaths: 0
res: 0
[18:19:52] [debug] Run time error 4: "Array index out of bounds"
[18:19:52] [debug] Attempted to read/write array element at index 65535 in array of size 100
[18:19:52] [debug] AMX backtrace:
[18:19:52] [debug] #0 0003fcb0 in ?? (0, 65535) from a.amx
[18:19:52] [debug] #1 0003f52c in public WC_OnPlayerDeath (0, 65535, 55) from a.amx
[18:19:52] [debug] #2 00015f18 in ?? (0, 0, 65535, 55, 0, 0) from a.amx
[18:19:52] [debug] #3 0000196c in ?? (0, 0, -1082130432) from a.amx
[18:19:52] [debug] #4 00044eb0 in public cmd_kills (0, 6149920) from a.amx
[18:19:52] [debug] #5 native CallLocalFunction () from samp-server.exe
[18:19:52] [debug] #6 00000710 in public OnPlayerCommandText (0, 6149892) from a.amx
Dayrion; say update the code with this
PHP Code:
if(killerid != INVALID_PLAYER_ID
like this

PHP Code:
public OnPlayerDeath(PIDkilleridreason

    if(
killerid != INVALID_PLAYER_ID
    { 

            if(
killerid != INVALID_PLAYER_ID
            { 
                
SetPlayerScore(killeridGetPlayerScore(killerid)+1); 
                
GivePlayerMoney(killerid4000); 
                
scm(killerid, -1"Congratulation!You have gained 4000$ and +2 score."); 
                
SetPlayerScore(PIDGetPlayerScore(PID) -1); 
                
GivePlayerMoney(PID, -2000); 
                
scm(PID, -1"You lost 2000$ because you noob."); 
            } 

            if(
god_mode[PID] == 1
            { 
                        
god_mode[PID] = 0
                        return 
1
            } 

            if(
killerid != INVALID_PLAYER_ID
            { 
             if(
InDM[PID] == true
             { 
               if(
anakko[PID] == 1
               { 
                    
anakko[PID] = 0
                     if(
makko[PID] != INVALID_PLAYER_ID
                    
TogglePlayerSpectating(PID1); 
                    
PlayerSpectatePlayer(PIDkillerid); 
                    
SendClientMessage(PIDSKYBLUE    "You have been killed, you are now spectating your killer."); 
                    
SetTimerEx("EndDeathCam"10000false"i"playerid); 
               } 
               else 
               { 
                    
TogglePlayerSpectating(PID0); 
                    
killstreak(PIDkillerid); 
                    
DestroyDynamic3DTextLabel(wanted[killerid]); 
                    return 
1
               } 
             } 
            } 

            
PlayerTextDrawHide(PID,Textdraw0); 
            
PlayerTextDrawHide(PID,Textdraw1); 
            
PlayerTextDrawHide(PID,Textdraw2); 
            
PlayerTextDrawHide(PID,Textdraw3); 
             
            
GameTextForPlayer(playerid,"~r~wasted",20004); 
            
gPlayerHasCitySelected[PID] = 0
            
anakko[PID] = 1
            
ClearAnimations(PID); 
            
rBit2_Set(UnderWaterPIDfalse); 
            
printf("OnPlayerDeath: playerid: %d, killerid; %d, reason: %s"playeridkilleridreason); 
            return 
1
    } 
    return 
1

PHP Code:
public OnPlayerDamage(&playerid, &Float:amount, &issuerid, &weapon, &bodypart)
{
        if(
god_mode[playerid])
            return 
0;

        if(
issuerid != INVALID_PLAYER_ID && bodypart == && !IsPlayerAdmin(playerid))// I recommend defining bodyparts.
        
{
            if(
IsPlayerConnected(issuerid))
            {
                new 
string[100], pname[24];
                
GetPlayerName(PIDheadshotsizeof(headshot));
                
GetPlayerName(issueridpnamesizeof(pname));
                
format(stringsizeof(string), "%s(%i) was shot in the head by %s(%i)"headshot,PIDpnameissuerid);
                
scms(0x800000AA,string);
                
GameTextForPlayer(issuerid,"~r~HeadShot",2000,1);
                
PlayerPlaySound(issuerid178020.00.00.0);// There is already a ding sound that you can play when someone gets shot.
                
GameTextForPlayer(PID,"~r~HeadShot",2000,1);
                
ClearAnimations(PID);
                
ApplyAnimation(PID"PED""ko2"4.1111111);// Redundant? People already play a custom animation when getting shot in the head and falling down in weapon-config.
                
PlayerPlaySound(PID178020.00.00.0);// There is already a ding sound that you can play when someone gets shot.
                
GivePlayerMoney(issuerid1000);
                
amount 0.0;// If you set the amount of damage to 0.0, it means that it kills the player. As is documented here: https://github.com/oscar-broman/samp-weapon-config#new-callbacks//Returning 1 to make sure that the damage gets applied right away.
                
return 1;
            }
        }
        else 
printf("OnPlayerDamage: playerid: %d, issuerid; %d, weapon: %i "playeridissueridbodypartweapon);
        return 
1;

i use Weapon config to make a headshot system.the log show this after update the code.but when go dm,the room is blank when die in dm mode the print not show and input lag.

PHP Code:
[10:29:39OnPlayerDeathplayerid0killerid65535reason7
[10:32:45OnPlayerDeathplayerid0killerid65535reason7
[10:33:12OnPlayerDeathplayerid0killerid65535reason3
[10:33:47OnPlayerDeathplayerid0killerid65535reason: %
[
10:35:57OnPlayerDeathplayerid0killerid65535reason: % 
in dm


when leave dm.the player spawn but he fall first and then he spawn




asri is offline   Reply With Quote
Old 11/08/2017, 12:06 PM   #17
Arthur Kane
Gangsta
 
Join Date: Sep 2012
Posts: 659
Reputation: 29
Default Re: bug

Your codes a literal mess.

Also, your first code. You're checking if it's an INVALID_PLAYER_ID three times.

Code:
public OnPlayerDeath(PID, killerid, reason)  
{  
    if(killerid != INVALID_PLAYER_ID)  
    {  

            if(killerid != INVALID_PLAYER_ID)  
            {  
                SetPlayerScore(killerid, GetPlayerScore(killerid)+1);  
                GivePlayerMoney(killerid, 4000);  
                scm(killerid, -1, "Congratulation!You have gained 4000$ and +2 score.");  
                SetPlayerScore(PID, GetPlayerScore(PID) -1);  
                GivePlayerMoney(PID, -2000);  
                scm(PID, -1, "You lost 2000$ because you noob.");  
            }  

            if(god_mode[PID] == 1)  
            {  
                        god_mode[PID] = 0;  
                       * return 1;  
            }  

            if(killerid != INVALID_PLAYER_ID)  
            {
What's even happening? What're you trying to do?

* You're returning true so if that was the instance then everything below wouldn't be called.
Arthur Kane is offline   Reply With Quote
Old 11/08/2017, 12:54 PM   #18
asri
Big Clucker
 
Join Date: May 2017
Location: Malaysia
Posts: 114
Reputation: 1
Default Re: bug

you mean like this
PHP Code:
public OnPlayerDeath(PIDkilleridreason)
{
    if(
killerid != INVALID_PLAYER_ID)
    {

            if(
gPlayerCitySelection[PID] == 1)
            {
                
SetPlayerScore(killeridGetPlayerScore(killerid)+1);
                
GivePlayerMoney(killerid4000);
                
scm(killerid, -1"Congratulation!You have gained 4000$ and +2 score.");
                
SetPlayerScore(PIDGetPlayerScore(PID) -1);
                
GivePlayerMoney(PID, -2000);
                
scm(PID, -1"You lost 2000$ because you noob.");
            }

            if(
god_mode[PID] == 1)
            {
               
god_mode[PID] = 0;
            }

            if(
InDM[PID] == true)
            {
               if(
anakko[PID] == 1)
               {
                    
anakko[PID] = 0;
                     if(
makko[PID] != INVALID_PLAYER_ID)
                    
TogglePlayerSpectating(PID1);
                    
PlayerSpectatePlayer(PIDkillerid);
                    
SendClientMessage(PIDSKYBLUE    "You have been killed, you are now spectating your killer.");
                    
SetTimerEx("EndDeathCam"10000false"i"playerid);
               }
               else
               {
                    
TogglePlayerSpectating(PID0);
                    
killstreak(PIDkillerid);
                    
DestroyDynamic3DTextLabel(wanted[killerid]);
                    return 
1;
               }
            }
            
PlayerTextDrawHide(PID,Textdraw0);
            
PlayerTextDrawHide(PID,Textdraw1);
            
PlayerTextDrawHide(PID,Textdraw2);
            
PlayerTextDrawHide(PID,Textdraw3);

            
GameTextForPlayer(playerid,"~r~wasted",20004);
            
gPlayerHasCitySelected[PID] = 0;
            
anakko[PID] = 1;
            
ClearAnimations(PID);
            
rBit2_Set(UnderWaterPIDfalse);
            return 
1;
    }
    else 
printf("OnPlayerDeath: playerid: %d, killerid; %d, reason: %s"playeridkilleridreason);
    return 
1;

asri is offline   Reply With Quote
Old 11/08/2017, 04:24 PM   #19
asri
Big Clucker
 
Join Date: May 2017
Location: Malaysia
Posts: 114
Reputation: 1
Default Re: bug

anyone
asri is offline   Reply With Quote
Old 11/08/2017, 10:35 PM   #20
Arthur Kane
Gangsta
 
Join Date: Sep 2012
Posts: 659
Reputation: 29
Default Re: bug

Code:
if(InDM[PID] == true) 
            { 
               if(anakko[PID] == 1) 
               { 
                    anakko[PID] = 0; 
                     if(makko[PID] != INVALID_PLAYER_ID) 
                    TogglePlayerSpectating(PID, 1); 
                    PlayerSpectatePlayer(PID, killerid); 
                    SendClientMessage(PID, SKYBLUE    , "You have been killed, you are now spectating your killer."); 
                    SetTimerEx("EndDeathCam", 10000, false, "i", playerid); 
               }
Remove this.
Arthur Kane is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT. The time now is 12:56 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.