SA-MP Forums Archive
OnPlayerKeyStateChange -,- - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: OnPlayerKeyStateChange -,- (/showthread.php?tid=486772)



OnPlayerKeyStateChange -,- - Raza2013 - 10.01.2014

hiya guys what's up today i got a problem of OnPlayerKeyStateChange i've made for rustler bombing but i'm getting the message while OnFoot so how i can remove it

HERE WE GO!

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(newkeys == KEY_FIRE)
    {
        if (IsPlayerInAnyVehicle(playerid) && GetVehicleModel(GetPlayerVehicleID(playerid)) != 476)
        {
            return SendClientMessage(playerid, 0xFF0000AA, "");
        }
        else
        {
            new Float:VBPos[3];
            new Float:X, Float:Y, Float:Z;
            GetVehiclePos(GetPlayerVehicleID(playerid),VBPos[0],VBPos[1],VBPos[2]);
            CreateExplosion(VBPos[0], VBPos[1], VBPos[2], 7, 20.0);
            GetPlayerPos(playerid, X, Y, Z); // this is a message which i'm getting it while on Foot
            format(Stringz, sizeof(Stringz), "You've droped a bomb at the Destination Of "cred"%0.0f, %0.0f, %0.0f ", X, Y, Z);
            SendClientMessage(playerid, orange, Stringz);// this is 2nd message
            GameTextForPlayer(playerid, "~n~~n~~n~~n~~>~~w~Bomb ~r~Droped~<~", 3000, 3);
        }
    }
    return 1;
}



Re: OnPlayerKeyStateChange -,- - amirab - 10.01.2014

delet this : && GetVehicleModel(GetPlayerVehicleID(playerid)) != 476
i tried this one and got answer

PHP код:
public OnPlayerKeyStateChange(playeridnewkeysoldkeys)
{
    if(
newkeys == KEY_FIRE)
    {
        if (
IsPlayerInAnyVehicle(playerid))
        {
            return 
SendClientMessage(playerid0xFF0000AA"");
        }
        else
        {
            new 
Float:VBPos[3];
            new 
Float:XFloat:YFloat:Z;
            
GetVehiclePos(GetPlayerVehicleID(playerid),VBPos[0],VBPos[1],VBPos[2]);
            
CreateExplosion(VBPos[0], VBPos[1], VBPos[2], 720.0);
            
GetPlayerPos(playeridXYZ); // this is a message which i'm getting it while on Foot
            
format(Stringzsizeof(Stringz), "You've droped a bomb at the Destination Of "cred"%0.0f, %0.0f, %0.0f "XYZ);
            
SendClientMessage(playeridorangeStringz);// this is 2nd message
            
GameTextForPlayer(playerid"~n~~n~~n~~n~~>~~w~Bomb ~r~Droped~<~"30003);
        }
    }
    return 
1;




Re: OnPlayerKeyStateChange -,- - Raza2013 - 10.01.2014

brah i want to remove the SendClientMessage while on foot that's why i'm here -___-
read the message before posting


Re: OnPlayerKeyStateChange -,- - Pottus - 10.01.2014

You'll want to use if(newkeys & KEY_FIRE) instead otherwise it will only be true if your pressing only the fire key.


Re: OnPlayerKeyStateChange -,- - Raza2013 - 10.01.2014

nvm code?


Re: OnPlayerKeyStateChange -,- - newbie scripter - 11.01.2014

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(newkeys & KEY_FIRE)
    {
        if (IsPlayerInAnyVehicle(playerid) && GetVehicleModel(GetPlayerVehicleID(playerid)) == 476)
        {
             new Float:VBPos[3];
            new Float:X, Float:Y, Float:Z;
            GetVehiclePos(GetPlayerVehicleID(playerid),VBPos[0],VBPos[1],VBPos[2]);
            CreateExplosion(VBPos[0], VBPos[1], VBPos[2], 7, 20.0);
            GetPlayerPos(playerid, X, Y, Z); // this is a message which i'm getting it while on Foot
            format(Stringz, sizeof(Stringz), "You've droped a bomb at the Destination Of "cred"%0.0f, %0.0f, %0.0f ", X, Y, Z);
            SendClientMessage(playerid, orange, Stringz);// this is 2nd message
            GameTextForPlayer(playerid, "~n~~n~~n~~n~~>~~w~Bomb ~r~Droped~<~", 3000, 3);
        }
    }
    return 1;
}