OnPlayerKeyStateChange
#1

So when i try to use taser, sprunk or enter house with "F" it doesnt work.

PHP код:
public OnPlayerKeyStateChange(playeridnewkeysoldkeys)
{
    if(
IsPlayerNPC(playerid)) return 1;
    
    
// Enter System
    
if ((newkeys KEY_SECONDARY_ATTACK) && !(oldkeys KEY_SECONDARY_ATTACK))
    {
        if(
GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
        {
            
SendToEnter(playerid);
            
SendToExit(playerid);
        }
    }
    if(
GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
    {
        if(
gPlayerUsingLoopingAnim[playerid] && (newkeys KEY_SPRINT) && !(oldkeys KEY_SPRINT))
        {
            
StopLoopingAnim(playerid);
            
TextDrawHideForPlayer(playerid,txtAnimHelper);
            return 
1;
        }
    }
    
// Galaxy S3
    
if(newkeys KEY_YES)
    {
        if(
GetPVarInt(playerid,"cameramode") == 1)
        {
            for(new 
032i++) TextDrawHideForPlayer(playerid,Galaxy3Camera[i]);
            
GalaxyS3Phone(playerid,1);
            for(new 
011i++) TextDrawShowForPlayer(playerid,Galaxy3StartMenu[i]);
            
PlayerTextDrawShow(playerid,Galaxy3StartMenu2);
            for(new 
013i++) TextDrawShowForPlayer(playerid,Galaxy3SMainMenu[i]);
            
SelectTextDraw(playerid,0x33AA33AA);
            
DeletePVar(playerid,"cameramode");
              
SetCameraBehindPlayer(playerid);
            
DestroyObject(firstpersona[playerid]);
        }
    }
    
// For Extinguishing Fire
    
if(PRESSED(newkeys KEY_FIRE) && IsNearFire(playerid) && GetPlayerState(playerid) == PLAYER_STATE_ONFOOT && HasExtinguisher(playerid))
    {
        new 
Float:poxFloat:poyFloat:poz;
        
GetPlayerPos(playeridpoxpoypoz);
        new 
fiire GetFireID(poxpoypoz10.0);
            if(
IsPlayerAimingAt(playeridFire[fiire][Fire_X], Fire[fiire][Fire_Y], Fire[fiire][Fire_Z], 10))
            {
                new 
putouttype 1;
                
ExtinguishFire[fiire] = SetTimerEx("PutOutFire",1000true"ii"fiireputouttype);
            }
    }
    if(
RELEASED(newkeys KEY_FIRE) && IsNearFire(playerid) && GetPlayerState(playerid) == PLAYER_STATE_ONFOOT && HasExtinguisher(playerid))
    {
        new 
Float:poxFloat:poyFloat:poz;
        
GetPlayerPos(playeridpoxpoypoz);
        new 
fiire GetFireID(poxpoypoz10.0);
        
KillTimer(ExtinguishFire[fiire]);
    }
    if(
PRESSED(newkeys KEY_FIRE) && IsNearFire(playerid) && IsInWaterCar(playerid))
    {
        new 
Float:poxFloat:poyFloat:poz;
        
GetPlayerPos(playeridpoxpoypoz);
        new 
fiire GetFireID(poxpoypoz10.0);
            if(
IsPlayerAimingAt(playeridFire[fiire][Fire_X], Fire[fiire][Fire_Y], Fire[fiire][Fire_Z], 10))
            {
                new 
putouttype 2;
                
ExtinguishFire[fiire] = SetTimerEx("PutOutFire",1000true"ii"fiireputouttype);
            }
    }
    if(
RELEASED(newkeys KEY_FIRE) && IsNearFire(playerid) && IsInWaterCar(playerid))
    {
        new 
Float:poxFloat:poyFloat:poz;
        
GetPlayerPos(playeridpoxpoypoz);
        new 
fiire GetFireID(poxpoypoz10.0);
        
KillTimer(ExtinguishFire[fiire]);
    }
    if(
newkeys KEY_YES)
    {
        if(
GetPlayerTargetPlayer(playerid) != INVALID_PLAYER_ID && ProxDetectorS(5.0playeridGetPlayerTargetPlayer(playerid)) && !IsPlayerNPC(GetPlayerTargetPlayer(playerid)))
        {
            new 
string[64];
            new 
name[MAX_PLAYER_NAME+8];
            
format(namesizeof(name), "{33CCFF}%s"GetPlayerNameEx(GetPlayerTargetPlayer(playerid)));
            
SetPVarString(playerid"pInteractName"name);
            
SetPVarInt(playerid"pInteractID"GetPlayerTargetPlayer(playerid));
            
format(stringsizeof(string), "Pay\nGive\n");
            if(
PlayerInfo[playerid][pJob] == || PlayerInfo[playerid][pJob2] == 4)
            {
                
format(stringsizeof(string), "%sSell\n"string);
            }
            if(
IsACop(playerid) || IsALVPDCop(playerid))
            {
                
format(stringsizeof(string), "%sFrisk\n"string);
            }
            
ShowPlayerDialog(playeridINTERACTMAINDIALOG_STYLE_LISTnamestring"Select""Cancel");
        }
    }
    if((
newkeys KEY_FIRE) && GetPVarInt(playerid"SpeedRadar") == && GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
    {
        if(
GetPVarInt(playerid"RadarTimeout") == 0)
        {
            if(
GetPlayerWeapon(playerid) == SPEEDGUN)
            {
                new 
Float:x,Float:y,Float:z;
                for(new 
veh 1veh MAX_VEHICLESveh++)
                {
                    if(
IsVehicleStreamedIn(vehplayerid))
                    {
                        
GetVehiclePos(veh,x,y,z);
                        if(
IsPlayerAimingAt(playerid,x,y,z,10))
                        {
                            new 
FloatSpeed GetVehicleSpeed(veh0);
                            new 
string[68];
                            
format(stringsizeof(string), "~n~~n~~n~~n~~n~~n~~b~License Plate: ~w~%d~n~~b~Speed: ~w~%d MPH"vehfloatround(Speed/1.609));
                            
GameTextForPlayer(playeridstring,35003);
                            
format(stringsizeof(string), "License Plate: %d Speed: %d MPH"vehfloatround(Speed/1.609));
                            
SendClientMessageEx(playeridCOLOR_GRAD4string);
                            
SetPVarInt(playerid"RadarTimeout"1);
                            
SetTimerEx("RadarCooldown"30000"i"playerid);
                            return 
1;
                        }
                    }
                }
            }
        }
    }
    if(
newkeys == 16 && Injourney[playerid] > 0)
    {
        new 
Float:XFloat:YFloat:Z;
        
GetVehiclePos(Injourney[playerid], XYZ);
        
SetPlayerPos(playeridX+4YZ);
        
SetPlayerInterior(playerid0);
        
SetPlayerVirtualWorld(playerid0);
        
PlayerInfo[playerid][pVW] = 0;
        
Injourney[playerid] = 0;
    }
    if((
newkeys KEY_NO) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
    {
        if(
IsACop(playerid) || IsALVPDCop(playerid) || PlayerInfo[playerid][pMember] == 20)
        {
            
VehicleLightSwitch(playerid);
            
GameTextForPlayer(playerid"~y~TOGGLED LIGHTS"10003);
        }
    }
    if((
newkeys KEY_FIRE) && pTazer[playerid] == && GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
    {
         if(
TazerTimeout[playerid] > 0)
          {
            return 
1;
        }
        new 
Float:XFloat:YFloat:Z;
        foreach(
Playeri)
        {
            if(
IsPlayerStreamedIn(iplayerid))
            {
                
GetPlayerPos(iXYZ);
                if(
IsPlayerAimingAt(playerid,X,Y,Z,1) && PlayerCuffed[i] == && GetPlayerState(i) == PLAYER_STATE_ONFOOT && (GetPlayerVirtualWorld(playerid) == GetPlayerVirtualWorld(i)))
                {
                     if(
PlayerInfo[i][pAdmin] >= 99999 && PlayerInfo[i][pTogReports] != 1)
                    {
                        
SendClientMessageEx(playeridCOLOR_GRAD2"Executive Admins can not be tazed!");
                        return 
1;
                    }
                    new 
string[44 + (MAX_PLAYER_NAME 2)];
                    
format(stringsizeof(string), "* %s gets hit by %s's tazer shot, stunning them."GetPlayerNameEx(i), GetPlayerNameEx(playerid));
                    
ProxDetector(30.0playeridstringCOLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                    
GameTextForPlayer(i"~r~Tazed"35003);
                    
TogglePlayerControllable(i0);
                    
ApplyAnimation(i,"CRACK","crckdeth2",4.1,0,1,1,1,1,1);
                    
PlayerPlaySound(i1085XYZ);
                    
PlayerPlaySound(playerid1085XYZ);
                    
PlayerCuffed[i] = 1;
                    
SetPVarInt(i"PlayerCuffed"1);
                    
PlayerCuffedTime[i] = 16;
                    
SetPVarInt(i"IsFrozen"1);
                    
//Frozen[i] = 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 
1;
                }
            }
        }
        new 
string[44 + (MAX_PLAYER_NAME 2)];
        
format(stringsizeof(string), "* %s fires a tazer shot, which doesn't hit anybody."GetPlayerNameEx(playerid));
        
ProxDetector(30.0playeridstringCOLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
        
        
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);
    }    
    if((
newkeys 16) && GetPVarInt(playerid,"UsingAnim") == && GetPVarInt(playerid"IsFrozen") == && GetPlayerState(playerid) == && PlayerCuffed[playerid] == && PlayerInfo[playerid][pBeingSentenced] == 0)
    {
        
ClearAnimations(playerid);
        
DeletePVar(playerid,"UsingAnim");
    }
    
#define KEY_AIM KEY_HANDBRAKE
    
if((newkeys KEY_AIM) && GetPVarInt(playerid,"UsingAnim") == && GetPVarInt(playerid"IsFrozen") == && GetPlayerState(playerid) == PLAYER_STATE_ONFOOT && PlayerCuffed[playerid] == && PlayerInfo[playerid][pBeingSentenced] == 0)
    {
        
ClearAnimations(playerid);
        
DeletePVar(playerid,"UsingAnim");
    }
    if(
GetPlayerSpecialAction(playerid) == SPECIAL_ACTION_DRINK_BEER && (newkeys KEY_FIRE))
    {
        if(
GetPVarInt(playerid"DrinkCooledDown") == 1)
        {
            new 
FloatcHealth;
            
GetPlayerHealth(playeridcHealth);
            if(
cHealth 100)
            {
                
SetPlayerHealth(playeridcHealth+5);
            }
            else
            {
                
SendClientMessageEx(playeridCOLOR_GREY"* You finish up the drink and throw it away.");
                
SetPlayerSpecialAction(playeridSPECIAL_ACTION_NONE);
            }
            
DeletePVar(playerid"DrinkCooledDown");
            
SetTimerEx("DrinkCooldown"25000"i"playerid);
            return 
1;
        }
    }
    if(
GetPlayerSpecialAction(playerid) == SPECIAL_ACTION_DRINK_WINE && (newkeys KEY_FIRE))
    {
        if(
GetPVarInt(playerid"DrinkCooledDown") == 1)
        {
            new 
FloatcHealth;
            
GetPlayerHealth(playeridcHealth);
            if(
cHealth 100)
            {
                
SetPlayerHealth(playeridcHealth+8);
            }
            else
            {
                
SendClientMessageEx(playeridCOLOR_GREY"* You finish up the drink and throw it away.");
                
SetPlayerSpecialAction(playeridSPECIAL_ACTION_NONE);
            }
            
DeletePVar(playerid"DrinkCooledDown");
            
SetTimerEx("DrinkCooldown"25000"i"playerid);
            return 
1;
        }
    }
    if(
GetPlayerSpecialAction(playerid) == SPECIAL_ACTION_DRINK_SPRUNK && (newkeys KEY_FIRE))
    {
        if(
GetPVarInt(playerid"DrinkCooledDown") == 1)
        {
            new 
FloatcHealth;
            
GetPlayerHealth(playeridcHealth);
            if(
cHealth 100)
            {
                
SetPlayerHealth(playeridcHealth+2);
            }
            else
            {
                
SendClientMessageEx(playeridCOLOR_GREY"* You finish up the drink and throw it away.");
                
SetPlayerSpecialAction(playeridSPECIAL_ACTION_NONE);
            }
            
DeletePVar(playerid"DrinkCooledDown");
            
SetTimerEx("DrinkCooldown"25000"i"playerid);
            return 
1;
        }
    }
    if(
IsKeyJustDown(KEY_SECONDARY_ATTACKnewkeysoldkeys))
    {
        if(
GetPVarInt(playerid"NGPassenger") == 1)
        {
            
TogglePlayerSpectating(playerid0);
        }
        if(
GetPVarInt(playerid"UsingSprunk"))
        {
            
DeletePVar(playerid"UsingSprunk");
            
SetPlayerSpecialAction(playeridSPECIAL_ACTION_NONE);
            return 
1;
        }
    }
    if (
IsKeyJustDown(KEY_FIREnewkeysoldkeys))
     {
         if( 
PlayerInfo[playerid][pC4Used] == )
         {
            if(
GoChase[playerid] < 999)
            {
                if(
IsPlayerInRangeOfPoint(GoChase[playerid], 12.0GetPVarFloat(playerid"DYN_C4_FLOAT_X"), GetPVarFloat(playerid"DYN_C4_FLOAT_Y"), GetPVarFloat(playerid"DYN_C4_FLOAT_Z")))
                {
                    if(
PlayerInfo[GoChase[playerid]][pHeadValue] >= 1)
                    {
                        if(
PlayerInfo[playerid][pMember] == || PlayerInfo[playerid][pLeader] == 8)
                        {
                            new 
string[128];
                            new 
takemoney PlayerInfo[GoChase[playerid]][pHeadValue] / 2;
                            
GivePlayerCash(playeridtakemoney);
                            
GivePlayerCash(GoChase[playerid], -takemoney);
                            
format(string,sizeof(string),"Hitman %s has fulfilled the contract on %s and collected $%d",GetPlayerNameEx(playerid),GetPlayerNameEx(GoChase[playerid]),PlayerInfo[GoChase[playerid]][pHeadValue] / 2);
                            
SendFamilyMessage(8COLOR_YELLOWstring);
                            
format(string,sizeof(string),"You have been critically injured by a Hitman and lost $%d!",takemoney);
                            
ResetPlayerWeaponsEx(GoChase[playerid]);
                            
// SpawnPlayer(GoChase[playerid]);
                            
SendClientMessageEx(GoChase[playerid], COLOR_YELLOWstring);
                            
PlayerInfo[GoChase[playerid]][pHeadValue] = 0;
                            
PlayerInfo[playerid][pCHits] += 1;
                            
SetPlayerHealth(GoChase[playerid], 0.0);
                            
// KillEMSQueue(GoChase[playerid]);
                            
GotHit[GoChase[playerid]] = 0;
                            
GetChased[GoChase[playerid]] = 999;
                            
GoChase[playerid] = 999;
                        }
                    }
                }
            }
             
PlayerInfo[playerid][pC4Used] = 0;
            
CreateExplosion(GetPVarFloat(playerid"DYN_C4_FLOAT_X"), GetPVarFloat(playerid"DYN_C4_FLOAT_Y"), GetPVarFloat(playerid"DYN_C4_FLOAT_Z"), 78);
            
PickUpC4(playerid);
            
SendClientMessageEx(playeridCOLOR_YELLOW" Bomb has been detonated!");
            
PlayerInfo[playerid][pC4Used] = 0;
            return 
1;
         }
         if(
GetPVarInt(playerid"MovingStretcher") != -1)
         {
             
KillTimer(GetPVarInt(playerid"TickEMSMove"));
            
MoveEMS(playerid);
            return 
1;
         }
         if(
GetPVarInt(playerid"DraggingPlayer") != -1)
         {
            
MoveCOP(playerid);
            return 
1;
         }
        if(
GetPVarInt(playerid"editingcdvehpos"))
        {
            
TogglePlayerControllable(playeridfalse);
            
ShowPlayerDialog(playerid,DIALOG_CDEDITPARK,DIALOG_STYLE_MSGBOX,"Warning:","Is this the new position you want?","Ok","Cancel");
        }
        if(
GetPVarInt(playerid"editingcdvehnew"))
        {
            
TogglePlayerControllable(playeridfalse);
            
ShowPlayerDialog(playerid,DIALOG_CDEDITPARK,DIALOG_STYLE_MSGBOX,"Warning:","Is this the new position you want?","Ok","Cancel");
        }
        if(
GetPVarInt(playerid"editingfamhq") != 255)
        {
            if(
GetPVarInt(playerid"editingfamhqaction") == 1)
            {
                  
DeletePVar(playerid"editingfamhqaction");
                
TogglePlayerControllable(playeridfalse);
                
ShowPlayerDialog(playerid,HQENTRANCE,DIALOG_STYLE_MSGBOX,"Warning:","Is this the entrance you want?","Ok","Cancel");
            }
            else if(
GetPVarInt(playerid"editingfamhqaction") == 2)
            {
                
DeletePVar(playerid"editingfamhqaction");
                
TogglePlayerControllable(playeridfalse);
                
ShowPlayerDialog(playerid,HQEXIT,DIALOG_STYLE_MSGBOX,"Warning:","Is this the exit you want?","Ok","Cancel");
            }
            else if(
GetPVarInt(playerid"editingfamhqaction") == 5)
            {
                
TogglePlayerControllable(playeridfalse);
                
ShowPlayerDialog(playerid,HQENTRANCE,DIALOG_STYLE_MSGBOX,"Warning:","Is this the entrance you want?","Ok","Cancel");
            }
            else if(
GetPVarInt(playerid"editingfamhqaction") == 6)
            {
                
TogglePlayerControllable(playeridfalse);
                
ShowPlayerDialog(playerid,HQEXIT,DIALOG_STYLE_MSGBOX,"Warning:","Is this the exit you want?","Ok","Cancel");
            }
        }
         new 
Float:health;
         
GetPlayerHealth(playeridhealth);
        if(
GetPVarInt(playerid"UsingSprunk"))
        {
            new 
hpint floatroundhealthfloatround_round );
            if( 
hpint >= 100 )
            {
                  
SendClientMessageEx(playeridCOLOR_GREY" You already have full health.");
                 return 
1;
               }
               else
               {
                
GetPlayerHealth(playeridhealth);
                
SetPlayerHealth(playeridhealth+1.0);
            }
        }
    }
    return 
1;

Reply
#2

Why are these like this:
PHP код:
if ((newkeys KEY_SECONDARY_ATTACK) && !(oldkeys KEY_SECONDARY_ATTACK)) 
I think it should be like this:
PHP код:
if ((newkeys == KEY_SECONDARY_ATTACK) && !(oldkeys == KEY_SECONDARY_ATTACK)) 
Reply
#3

Are you sure that "F" is "KEY_SECONDARY_ATTACK" try to getin with "Enter" as it's the default, try to get in with enter, also make a debug to make sure the callback is being called

pawn Код:
if ((newkeys & KEY_SECONDARY_ATTACK) && !(oldkeys & KEY_SECONDARY_ATTACK))
    {
        if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
        {
            SendClientMessage(playerid, -1, "The callback is being called, the problem might be in ""SendToEnter"" or ""SendToExit"");
            SendToEnter(playerid);
            SendToExit(playerid);
        }
    }
Quote:
Originally Posted by ATGOggy
Посмотреть сообщение
Why are these like this:
PHP код:
if ((newkeys KEY_SECONDARY_ATTACK) && !(oldkeys KEY_SECONDARY_ATTACK)) 
I think it should be like this:
PHP код:
if ((newkeys == KEY_SECONDARY_ATTACK) && !(oldkeys == KEY_SECONDARY_ATTACK)) 
Read this.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)