SA-MP Forums Archive
Why is this not working? - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Why is this not working? (/showthread.php?tid=103451)



Why is this not working? - BP13 - 19.10.2009

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(newkeys == KEY_CROUCH)
    {
        new
            Float:x,
            Float:y,
            Float:z;
        GetVehiclePos(playerid, x, y, z);
        SetVehiclePos(playerid, x, y, z + 10.0); //This thing ^doesnt do anything at all (suppose to be a superjump for cars)
    }
  if(newkeys == KEY_FIRE)
    {
      if(IsPlayerInAnyVehicle(playerid))
        {
        new Float:s[3];
          GetVehicleVelocity(GetPlayerVehicleID(playerid),s[0],s[1],s[2]);
          s[0]=1.5*s[0];
          s[1]=1.5*s[1];
          s[2]=1.5*s[2];
          SetVehicleVelocity(GetPlayerVehicleID(playerid),s[0],s[1],s[2]); // This thing ^ only works if you are pressing alt with no other keys pressed.
        }
        return 1;
    }
    return 1;
}

any help?


Re: Why is this not working? - Gerinych - 20.10.2009

Try this:
Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(newkeys & KEY_CROUCH) //apparently, you're supposed to use "&", not "=="
{
new
Float:x,
Float:y,
Float:z;
GetVehiclePos(playerid, x, y, z);
SetVehiclePos(playerid, x, y, z + 10.0); //This thing ^doesnt do anything at all (suppose to be a superjump for cars)
}
  if(newkeys & KEY_FIRE) //same thing
{
  if(IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER) //you might also want to put this in, it makes it so that the passenger can't use the jump button.
{
  new Float:s[3];
  GetVehicleVelocity(GetPlayerVehicleID(playerid),s[0],s[1],s[2]);
  s[0]=1.5*s[0];
  s[1]=1.5*s[1];
  s[2]=1.5*s[2];
  SetVehicleVelocity(GetPlayerVehicleID(playerid),s[0],s[1],s[2]); // This thing ^ only works if you are pressing alt with no other keys pressed.
}
return 1;
}
return 1;
}



Re: Why is this not working? - Zeex - 20.10.2009

pawn Код:
GetVehiclePos(playerid, x, y, z);
SetVehiclePos(playerid, x, y, z + 10.0); //This thing ^doesnt do anything at all (suppose to be a superjump for cars)
Those functions need vehicleid but you're passing playerid to them, that's why it doesn't work (or maybe you are vehicle?)

And read this tutorial > https://sampwiki.blast.hk/wiki/OnPlayerKeyStateChange



Re: Why is this not working? - BP13 - 20.10.2009

the super jump is still not working. Its even the one copied from SA:MP wiki and it doesnt work. Right now I have This and its not doing anything. what do I have to change?

pawn Код:
if(PRESSED(KEY_CROUCH))
    {
        if(PlayerIsInDM[playerid] == true)
        {
            SendClientMessage(playerid,COLOR_RED, "ERROR: You can't use this command in DM zone! Use /exitdm ");
        }
        if(IsPlayerInAnyVehicle(playerid) && PlayerIsInDM[playerid] == false)
        {
            new
                Float:x,
                Float:y,
                Float:z;
            GetVehiclePos(playerid, x, y, z);
            SetVehiclePos(playerid, x, y, z + 10.0);
        }
    }



Re: Why is this not working? - whooper - 20.10.2009

pawn Код:
if(PRESSED(KEY_CROUCH))
{
if(PlayerIsInDM[playerid] == true)
  {
SendClientMessage(playerid,COLOR_RED, "ERROR: You can't use this command in DM zone! Use /exitdm ");
}
if(IsPlayerInAnyVehicle(playerid) && PlayerIsInDM[playerid] == false)
{
new
pidofveh = GetPlayerVehicleID(playerid))
Float:x,
Float:y,
Float:z;
GetVehiclePos(pidofveh, x, y, z);
SetVehiclePos(pidofveh, x, y, z + 10.0);
}
}



Re: Why is this not working? - BP13 - 20.10.2009

Код:
C:\DOCUME~1\User\Desktop\MYNEWE~1\GAMEMO~1\SU.pwn(22520) : error 001: expected token: ";", but found ")"
C:\DOCUME~1\User\Desktop\MYNEWE~1\GAMEMO~1\SU.pwn(22520) : error 029: invalid expression, assumed zero
C:\DOCUME~1\User\Desktop\MYNEWE~1\GAMEMO~1\SU.pwn(22521) : warning 221: label name "Float" shadows tag name
C:\DOCUME~1\User\Desktop\MYNEWE~1\GAMEMO~1\SU.pwn(22521) : error 017: undefined symbol "x"
C:\DOCUME~1\User\Desktop\MYNEWE~1\GAMEMO~1\SU.pwn(22521 -- 22523) : warning 215: expression has no effect
C:\DOCUME~1\User\Desktop\MYNEWE~1\GAMEMO~1\SU.pwn(22524) : error 017: undefined symbol "x"
C:\DOCUME~1\User\Desktop\MYNEWE~1\GAMEMO~1\SU.pwn(22525) : error 017: undefined symbol "x"
C:\DOCUME~1\User\Desktop\MYNEWE~1\GAMEMO~1\SU.pwn(22521) : warning 203: symbol is never used: "Float"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


5 Errors.



Re: Why is this not working? - whooper - 20.10.2009

pawn Код:
if(PRESSED(KEY_CROUCH))
{
if(PlayerIsInDM[playerid] == true)
  {
SendClientMessage(playerid,COLOR_RED, "ERROR: You can't use this command in DM zone! Use /exitdm ");
}
if(IsPlayerInAnyVehicle(playerid) && PlayerIsInDM[playerid] == false)
{
new
Float:x,
Float:y,
Float:z;
GetVehiclePos(GetPlayerVehicleID(playerid), x, y, z);
SetVehiclePos(GetPlayerVehicleID(playerid), x, y, z + 10.0);
}
}



Re: Why is this not working? - BP13 - 20.10.2009

well taht works. but I was hoping to get it so when you use super jump it keeps your speed and doesnt just puts you straight up. So if im going a certain speed I superjump in the direction that im driving. Just like on GamerX


Re: Why is this not working? - whooper - 20.10.2009

Did you try what the one guy said.
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(newkeys & KEY_CROUCH) //apparently, you're supposed to use "&", not "=="
{
new
Float:x,
Float:y,
Float:z;

}
  if(newkeys & KEY_FIRE) //same thing
{
  if(IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER) //you might also want to put this in, it makes it so that the passenger can't use the jump button.
{
GetVehiclePos(GetPlayerVehicleID(playerid), x, y, z);
  new Float:s[3];
  GetVehicleVelocity(GetPlayerVehicleID(playerid),s[0],s[1],s[2]);
  s[0]=1.5*s[0];
  s[1]=1.5*s[1];
  s[2]=1.5*s[2];
  SetVehicleVelocity(GetPlayerVehicleID(playerid),s[0],s[1],s[2]); // This thing ^ only works if you are pressing alt with no other keys pressed.
}
return 1;
}
return 1;
}



Re: Why is this not working? - BP13 - 20.10.2009

Quote:
Originally Posted by whooper
Did you try what the one guy said.
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(newkeys & KEY_CROUCH) //apparently, you're supposed to use "&", not "=="
{
new
Float:x,
Float:y,
Float:z;

}

yes it doesnt work
  if(newkeys & KEY_FIRE) //same thing
{
  if(IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER) //you might also want to put this in, it makes it so that the passenger can't use the jump button.
{
GetVehiclePos(GetPlayerVehicleID(playerid), x, y, z);
  new Float:s[3];
  GetVehicleVelocity(GetPlayerVehicleID(playerid),s[0],s[1],s[2]);
  s[0]=1.5*s[0];
  s[1]=1.5*s[1];
  s[2]=1.5*s[2];
  SetVehicleVelocity(GetPlayerVehicleID(playerid),s[0],s[1],s[2]); // This thing ^ only works if you are pressing alt with no other keys pressed.
}
return 1;
}
return 1;
}