SA-MP Forums Archive
What's wrong with this simple script? (MegaJump) - 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: What's wrong with this simple script? (MegaJump) (/showthread.php?tid=423218)



What's wrong with this simple script? (MegaJump) - Vytixz - 17.03.2013

dasdasdadsa


Re: What's wrong with this simple script? (MegaJump) - JaKe Elite - 17.03.2013

the function PRESSED must be placed in OnPlayerKeyStateChange not in a command.


Re: What's wrong with this simple script? (MegaJump) - Vytixz - 17.03.2013

dsaasdsada


Re: What's wrong with this simple script? (MegaJump) - JaKe Elite - 17.03.2013

No that's not how it works.
You need a var. Set it to 1.
If 0, Then megajump from OnPlayerKeyStateChange will be blocked.
But when it's 1. Then it will be worked. Simple eh?

pawn Код:
new MegaJump[MAX_PLAYERS]; //at the top of the script

#define PRESSED(%0) \
(((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))

public OnPlayerConnect(playerid)
{
    MegaJump[playerid] = 0;
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    MegaJump[playerid] = 0;
    return 1;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(MegaJump[playerid] == 1)
    {
        if(PRESSED(KEY_JUMP))
        {
            new Float:P[3];
            GetPlayerPos(playerid,P[0],P[1],P[2]);
            GetPlayerVelocity(playerid,P[0],P[1],P[2]);
            SetPlayerVelocity(playerid,P[0],P[1],P[2]+5.0);
        }
    }
    return 1;
}

CMD:megajump(playerid, params[])
{
    if(MegaJump[playerid] == 0)
    {
        //Messages, Sound etc...
        MegaJump[playerid] = 1;
    }
    else if(MegaJump[playerid] == 1)
    {
        //Messages, Sound etc...
        MegaJump[playerid] = 0;
    }
    return 1;
}



Re: What's wrong with this simple script? (MegaJump) - Vytixz - 17.03.2013

dsadasdadada


Re: What's wrong with this simple script? (MegaJump) - Gamer_007 - 17.03.2013

Quote:
Originally Posted by Vytixz
Посмотреть сообщение
Can someone place this as a filterscript please? :/ I'm getting errors with my gamemode
Can you show ur gamemode, then we can place it.


Re: What's wrong with this simple script? (MegaJump) - Vytixz - 17.03.2013

dsadasdadsa