OnPlayerKeyStateChange
#1

PHP код:
public OnPlayerKeyStateChange(playeridnewkeysoldkeys)
{
    if(
newkeys KEY_FIRE && !HoldingKey[playerid])
    {
        
KeyCheck(playerid);
        
HoldingKey[playerid] = true;
    }
    return 
true;

PHP код:
Server:KeyCheck(playerid)
{
    if(
IsPlayerConnected(playerid))
    {
        new 
keysudlr;
        
GetPlayerKeys(playeridkeysudlr);
        if(
keys KEY_FIRE && IsPlayerUsingFireExting(playerid))
        {
            
SendClientMessage(playeridCOLOR_WHITE"[DEBUG]: Fire key is being held down for fire extinguisher.");
            
SetTimerEx("KeyCheck"5000"i"playerid);
        }
    }
    
HoldingKey[playerid] = false;
    return 
false;

PHP код:
IsPlayerUsingFireExting(playerid)
{
    if(
CurrentWeaponID[playerid] == 42) return true;
    else return 
false;

Hey guys! I was just experiencing a little issue that I'm not quite able to figure out so I thought I'd run it by some of you guys.

Currently, All of this functions 100% correct but when I use another weapon or hold down the KEY_FIRE with no weapon and then try to use the extinguisher again, then it doesn't function anymore until a restart. Any ideas? Am I missing something obvious?

Thanks ahead of time!
Reply
#2

Bump
Reply
#3

https://sampwiki.blast.hk/wiki/OnPlayerK..._holding_a_key

24 hour bumps only as well.

You should just use the natives, rather than making the check lag out like that.

You can easily just put in GetPlayerWeapon into the if statement, rather than have it run a check in another function, other than IsPLayerUsingFireExting...


Less, is better.
Reply
#4

Quote:
Originally Posted by Sew_Sumi
Посмотреть сообщение
.
The function "IsPlayerUsingFireExting" is currently dumbed down for debugging purposes, originally it checks much more than just the weapon ID otherwise I would be using solely the native functions but I reverted it all the way back to make it simple to try and figure the issue out. And again, Everything functions 100% as intended until I switch weapons away from the extinguisher and then back to it, Then it no longer sends me the debug message until a server restart.



EDIT: I re read what you said and looked over the code again and got it figured out. Thanks for the helpful response.
Reply
#5

Awesome.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)