SA-MP Forums Archive
KeyStateChange - 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: KeyStateChange (/showthread.php?tid=177601)



KeyStateChange - FireCat - 18.09.2010

Help /me whispers *stupid warning* xD
Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(IsPlayerInAnyVehicle(playerid)== 1)
    {
    if (PRESSED(KEY_SUBMISSION)) // Change KEY_SUBMISSION to your choice of PlayerKeys
    {
        new Float:x, Float:y, Float:z;
    GetVehicleVelocity(GetPlayerVehicleID(playerid), x, y, z);
    SetVehicleVelocity(GetPlayerVehicleID(playerid) ,x ,y ,z+0.3);
    {
    if (PRESSED(KEY_CROUCH))
    {
        new vehicle;
        new Float:zangle;
        vehicle = GetPlayerVehicleID(playerid);
        GetVehicleZAngle(vehicle,zangle);
        SetVehicleZAngle(vehicle,zangle);
    }
    return 1;
   }
  }
 }
}
warning:
Quote:

C:\Users\james\Desktop\server2\gamemodes\gamemode. pwn(386) : warning 209: function "OnPlayerKeyStateChange" should return a value
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


1 Warning.




Re: KeyStateChange - Matej_ - 18.09.2010

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(IsPlayerInAnyVehicle(playerid)== 1)
    {
    if (PRESSED(KEY_SUBMISSION)) // Change KEY_SUBMISSION to your choice of PlayerKeys
    {
        new Float:x, Float:y, Float:z;
    GetVehicleVelocity(GetPlayerVehicleID(playerid), x, y, z);
    SetVehicleVelocity(GetPlayerVehicleID(playerid) ,x ,y ,z+0.3);
    } // You puted > { instead of  > }
    if (PRESSED(KEY_CROUCH))
    {
        new vehicle;
        new Float:zangle;
        vehicle = GetPlayerVehicleID(playerid);
        GetVehicleZAngle(vehicle,zangle);
        SetVehicleZAngle(vehicle,zangle);
    }
    return 1;
   }
  }
 }
}



Re: KeyStateChange - FireCat - 18.09.2010

i still get the warning
Quote:

C:\Users\james\Desktop\server2\gamemodes\gamemode. pwn(384) : warning 209: function "OnPlayerKeyStateChange" should return a value
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


1 Warning.




Re: KeyStateChange - Hiddos - 18.09.2010

That's not the problem Matej ^^.

You're returning '1', but not in the head brackets:

pawn Код:
public Function()
{ //Head brackets
  if(a == b)
  { //Sub brackets
    stuff;
  }
}
If you're returning something in the sub brackets, you also need to return something in the head brackets.

So your code will become:

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(IsPlayerInAnyVehicle(playerid)== 1)
    {
    if (PRESSED(KEY_SUBMISSION)) // Change KEY_SUBMISSION to your choice of PlayerKeys
    {
        new Float:x, Float:y, Float:z;
    GetVehicleVelocity(GetPlayerVehicleID(playerid), x, y, z);
    SetVehicleVelocity(GetPlayerVehicleID(playerid) ,x ,y ,z+0.3);
    } // You puted > { instead of  > }
    if (PRESSED(KEY_CROUCH))
    {
        new vehicle;
        new Float:zangle;
        vehicle = GetPlayerVehicleID(playerid);
        GetVehicleZAngle(vehicle,zangle);
        SetVehicleZAngle(vehicle,zangle);
    }
   }
  }
 }
 return 1;
}



Re: KeyStateChange - FireCat - 18.09.2010

hiddos now no warning but yes a error >.>
Quote:

C:\Users\james\Desktop\server2\gamemodes\gamemode. pwn(384) : error 010: invalid function or declaration
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


1 Error.




Re: KeyStateChange - Matej_ - 18.09.2010

Quote:
Originally Posted by FireCat
Посмотреть сообщение
hiddos now no warning but yes a error >.>
copy line 384 here.


Re: KeyStateChange - FireCat - 18.09.2010

its return 1; line but here
Quote:

}
}
}
return 1; //line 384
}




Re: KeyStateChange - Matej_ - 18.09.2010

Quote:
Originally Posted by FireCat
Посмотреть сообщение
its return 1; line but here
try putting it more to the right side, click on it and press TAB once !


Re: KeyStateChange - MadeMan - 18.09.2010

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(IsPlayerInAnyVehicle(playerid)== 1)
    {
        if (PRESSED(KEY_SUBMISSION)) // Change KEY_SUBMISSION to your choice of PlayerKeys
        {
            new Float:x, Float:y, Float:z;
            GetVehicleVelocity(GetPlayerVehicleID(playerid), x, y, z);
            SetVehicleVelocity(GetPlayerVehicleID(playerid) ,x ,y ,z+0.3);
        }
        if (PRESSED(KEY_CROUCH))
        {
            new vehicle;
            new Float:zangle;
            vehicle = GetPlayerVehicleID(playerid);
            GetVehicleZAngle(vehicle,zangle);
            SetVehicleZAngle(vehicle,zangle);
        }
    }
    return 1;
}



Re: KeyStateChange - FireCat - 18.09.2010

thanks mademan
hiddos it cant be always you saving me xD