KeyStateChange
#1

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.

Reply
#2

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;
   }
  }
 }
}
Reply
#3

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.

Reply
#4

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;
}
Reply
#5

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.

Reply
#6

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

its return 1; line but here
Quote:

}
}
}
return 1; //line 384
}

Reply
#8

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 !
Reply
#9

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;
}
Reply
#10

thanks mademan
hiddos it cant be always you saving me xD
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)