/Superjump
#1

The code compile properly, but it doesn't work in game

Код:
CMD:superjump( playerid, params[ ] )
{
    #pragma unused params
    if(PlayerInfo[playerid][SjKey] == 0)
    {
    	PlayerInfo[playerid][SjKey] = 1;
    	SendClientMessage(playerid, COLOR_RED, "You turned off Super Jump {00FF00}(/Superjump)");
    }
    else
    {
    	PlayerInfo[playerid][SjKey] = 0;
    	SendClientMessage(playerid, COLOR_RED, "You turned on Super Jump. Press {00FF00}LShift {FF0000}to use it");
    }
}

if ( newkeys & KEY_JUMP && PlayerInfo[ playerid ][ SjKey ] == 1 )
    {
            new Float:SuperJump[3];
    	    GetPlayerVelocity(playerid, SuperJump[0], SuperJump[1], SuperJump[2]);
    	    SetPlayerVelocity(playerid, SuperJump[0], SuperJump[1], SuperJump[2]+5);
            return ( 1 );
    }
Any idea ?
Reply
#2

pawn Код:
CMD:superjump( playerid, params[ ] )
{
    #pragma unused params
    if(PlayerInfo[playerid][SjKey] == 0)
    {
        PlayerInfo[playerid][SjKey] = 0;
        SendClientMessage(playerid, COLOR_RED, "{00FFCC}[AFS]{FF0000}You turned off Super Jump {00FF00}(/Superjump)");
    }
    else
    {
        PlayerInfo[playerid][SjKey] = 1;
        SendClientMessage(playerid, COLOR_RED, "{00FFCC}[AFS]{FF0000}You turned on Super Jump. Press {00FF00}LShift {FF0000}to use it");
    }
}

if ( newkeys & KEY_JUMP && PlayerInfo[ playerid ][ SjKey ] == 1 )
    {
            new Float:SuperJump[3];
            GetPlayerVelocity(playerid, SuperJump[0], SuperJump[1], SuperJump[2]);
            SetPlayerVelocity(playerid, SuperJump[0], SuperJump[1], SuperJump[2]+5);
            return ( 1 );
    }
Reply
#3

I don't see any change
Reply
#4

Quote:
Originally Posted by Flokx
Посмотреть сообщение
I don't see any change
Look closer then..
You had your SjKey set to 1 when it turned off and 0 when it was on
Reply
#5

Thanks, Here is the new code
Код:
CMD:superjump( playerid, params[ ] )
{
    #pragma unused params
    if(PlayerInfo[playerid][SjKey] == 0)
    {
    	PlayerInfo[playerid][SjKey] = 1;
    	SendClientMessage(playerid, COLOR_RED, "You turned on Super Jump. Press {00FF00}LShift {FF0000}to use it");
    }
    else if(PlayerInfo[playerid][SjKey] == 1)
    {
    	PlayerInfo[playerid][SjKey] = 0;
    	SendClientMessage(playerid, COLOR_RED, "You turned off Super Jump {00FF00}(/Superjump)");
    }
}

if ( newkeys & KEY_JUMP && PlayerInfo[ playerid ][ SjKey ] == 1 )
    {
            new Float:SuperJump[3];
    	    GetPlayerVelocity(playerid, SuperJump[0], SuperJump[1], SuperJump[2]);
    	    SetPlayerVelocity(playerid, SuperJump[0], SuperJump[1], SuperJump[2]+5);
            return ( 1 );
    }
Still won't work
Reply
#6

Quote:
Originally Posted by Kinglee
Посмотреть сообщение
pawn Код:
CMD:superjump( playerid, params[ ] )
{
    #pragma unused params
    if(PlayerInfo[playerid][SjKey] == 0)
    {
        PlayerInfo[playerid][SjKey] = 0;
        SendClientMessage(playerid, COLOR_RED, "{00FFCC}[AFS]{FF0000}You turned off Super Jump {00FF00}(/Superjump)");
    }
    else
    {
        PlayerInfo[playerid][SjKey] = 1;
        SendClientMessage(playerid, COLOR_RED, "{00FFCC}[AFS]{FF0000}You turned on Super Jump. Press {00FF00}LShift {FF0000}to use it");
    }
}
Your code will turn off superjump when it's already turned off, and it will turn it on when it's already on.

Use this instead.
pawn Код:
CMD:superjump(playerid)
{
    if(PlayerInfo[playerid][SjKey] == 1)
    {
        PlayerInfo[playerid][SjKey] = 0;
        SendClientMessage(playerid, COLOR_RED, "{00FFCC}[AFS]{FF0000}You turned off Super Jump {00FF00}(/Superjump)");
    }
    else
    {
        PlayerInfo[playerid][SjKey] = 1;
        SendClientMessage(playerid, COLOR_RED, "{00FFCC}[AFS]{FF0000}You turned on Super Jump. Press {00FF00}LShift {FF0000}to use it");
    }
    return 1;
}
Reply
#7

pawn Код:
//at the top will be good under the includes//
new Float:SuperJump[3];
//anywhere outside all the call backs//
CMD:superjump( playerid, params[ ] )
{
    #pragma unused params
    if(PlayerInfo[playerid][SjKey] == 1)
    {
        PlayerInfo[playerid][SjKey] = 0;
        SendClientMessage(playerid, COLOR_RED, "You turned off Super Jump {00FF00}(/Superjump)");
        return 1;
    }
    else
    {
        PlayerInfo[playerid][SjKey] = 1;
        SendClientMessage(playerid, COLOR_RED, "You turned on Super Jump. Press {00FF00}LShift {FF0000}to use it");
        return 1;
    }
    return 1;
}
//onplayerkeystatechange//
    if ( newkeys & KEY_JUMP && PlayerInfo[ playerid ][ SjKey ] == 1 )
    {
        SetPlayerVelocity(playerid, SuperJump[0], SuperJump[1], SuperJump[2]+5);
        return 1;
    }
//At Onplayerupdate//
         GetPlayerVelocity(playerid, SuperJump[0], SuperJump[1], SuperJump[2]);
Tested! works fine for me.
Reply
#8

Quote:
Originally Posted by IamPRO
Посмотреть сообщение
pawn Код:
//at the top will be good under the includes//
new Float:SuperJump[3];
//anywhere outside all the call backs//
CMD:superjump( playerid, params[ ] )
{
    #pragma unused params
    if(PlayerInfo[playerid][SjKey] == 1)
    {
        PlayerInfo[playerid][SjKey] = 0;
        SendClientMessage(playerid, COLOR_RED, "You turned off Super Jump {00FF00}(/Superjump)");
        return 1;
    }
    else
    {
        PlayerInfo[playerid][SjKey] = 1;
        SendClientMessage(playerid, COLOR_RED, "You turned on Super Jump. Press {00FF00}LShift {FF0000}to use it");
        return 1;
    }
    return 1;
}
//onplayerkeystatechange//
    if ( newkeys & KEY_JUMP && PlayerInfo[ playerid ][ SjKey ] == 1 )
    {
        SetPlayerVelocity(playerid, SuperJump[0], SuperJump[1], SuperJump[2]+5);
        return 1;
    }
//At Onplayerupdate//
         GetPlayerVelocity(playerid, SuperJump[0], SuperJump[1], SuperJump[2]);
Tested! works fine for me.
The SuperJump variable doesn't need to be a global it was fine within the scope of OnPlayerKeyStateChange (Local variable).
Reply
#9

Quote:
Originally Posted by thefatshizms
Посмотреть сообщение
The SuperJump variable doesn't need to be a global it was fine within the scope of OnPlayerKeyStateChange (Local variable).
I am getting the player's velocity on player update, it will be not possible without it -_-
Reply
#10

Quote:
Originally Posted by IamPRO
Посмотреть сообщение
I am getting the player's velocity on player update, it will be not possible without it -_-
That's a complete waste of resources and time, you only need the variable when the player presses the desired button and won't be that often (maybe some short bursts but I doubt the player will be spamming the button the entire time playing on the server) and so it would be better to get the velocity during button press instead of hundreds of times a second.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)