PDA

View Full Version : Help!!!!!!!!!!!!!!!!!!!!!!!!


Mouiz
10/07/2015, 09:24 PM
How can i use newstate,oldstate,newkeys,oldkeys
if i use them together so i get error

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys, newstate,oldstate)
{
if (newkeys & KEY_SECONDARY_ATTACK)
{
if(ControllingShip[playerid] == 1)
{
ControllingShip[playerid] = 0;
new Float:X,Float:Y,Float:Z;
GetPlayerPos(playerid, X,Y,Z);
SetPlayerPos(playerid, X,Y+2,Z+6);
SetCameraBehindPlayer(playerid);
DestroyObject(Camera);
}
}

if (newkeys & KEY_FIRE)
{
if (!IsPlayerInAnyVehicle(playerid)) return 1;

if (GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return 1;

if (GetVehicleModel(GetPlayerVehicleID(playerid)) == 411)
{
AddVehicleComponent(GetPlayerVehicleID(playerid), 1010);
}
}

if((newkeys == KEY_JUMP && oldkeys == KEY_JUMP)&&(IsJumping[playerid] == 0))
{
if(PlayerInfo[playerid][pVip] >= 1)
IsJumping[playerid] = 1;
GetPlayerHealth(playerid, FirstHealth[playerid]);
SetPlayerVelocity(playerid,0.0,0.0,0.5);
SetTimerEx("JumpTimer", 5000, 0, "i", playerid);
}
else if(newkeys & KEY_JUMP)
{
if (MegaJump[playerid] == 1)
{
new Float:Jump[3];
GetPlayerVelocity(playerid, Jump[0], Jump[1], Jump[2]);
SetPlayerVelocity(playerid, Jump[0], Jump[1], Jump[2]+5);
}
}
if ( HOLDING( KEY_FIRE ) && GetPlayerState( playerid ) == PLAYER_STATE_DRIVER )
{
AddVehicleComponent( GetPlayerVehicleID( playerid ), 1010 );
}
if ( RELEASED( KEY_FIRE ) && GetPlayerState( playerid ) == PLAYER_STATE_DRIVER )
{
RemoveVehicleComponent( GetPlayerVehicleID( playerid ), 1010 );
}
if(IsPlayerInAnyVehicle(playerid))
{
if(newkeys & KEY_CROUCH)
{
new Float: P[ 4 ];
GetPlayerPos( playerid, P[ 0 ], P[ 1 ], P[ 2 ] );
GetVehicleZAngle( GetPlayerVehicleID( playerid ) , P[ 3 ]);
SetVehiclePos( GetPlayerVehicleID( playerid ), P[ 0 ], P[ 1 ], P[ 2 ] );
SetVehicleZAngle( GetPlayerVehicleID( playerid ), P[ 3 ] );
}
if(newkeys & KEY_YES)
{
new Float:x, Float:y, Float:z;
GetVehicleVelocity(GetPlayerVehicleID(playerid), x, y, z);
SetVehicleVelocity(GetPlayerVehicleID(playerid), x, y, z + 0.2);
}
else if(newkeys & KEY_SUBMISSION)
{
new Float:vx,Float:vy,Float:vz;
GetVehicleVelocity(GetPlayerVehicleID(playerid),vx ,vy,vz);
SetVehicleVelocity(GetPlayerVehicleID(playerid), vx * 1.8, vy *1.8, vz * 1.8);
}
}
if(newkeys & KEY_SECONDARY_ATTACK )
{
SetPlayerSpecialAction(playerid, 0);
}
if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
{
VehicleModel[playerid] = GetVehicleModel(GetPlayerVehicleID(playerid));
ShowGameTextForPlayer(playerid);
return 1;
}
if(newstate != PLAYER_STATE_DRIVER && (oldstate == PLAYER_STATE_DRIVER || oldstate == PLAYER_STATE_PASSENGER)) KillTimer(CFCTimer); //kills timer that checks for left vehicle if player exits vehicle
return 1;
}

error 025: function heading differs from prototype

Moudix
10/07/2015, 10:51 PM
What errors you're getting ?

DavidLuango
10/07/2015, 10:55 PM
If you want us to help, at least provide us the error information..?

Mouiz
11/07/2015, 11:03 AM
error 025: function heading differs from prototype

Mouiz
11/07/2015, 11:50 AM
please anyone help

KillerDVX
11/07/2015, 12:01 PM
Update your includes to 0.3.7 ones.

That will surely works ^^.

KillerDVX,

Mouiz
11/07/2015, 12:03 PM
Update your includes to 0.3.7 ones.

That will surely works ^^.

KillerDVX,

i have latest includes

Younes44
11/07/2015, 12:04 PM
then try to re-update them again

KillerDVX
11/07/2015, 12:05 PM
You are using an old functions,

Try this one :

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys);

KillerDVX,

Mouiz
11/07/2015, 12:10 PM
i am using this new one

KillerDVX
11/07/2015, 12:15 PM
As i saw :

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys, newstate,oldstate) // Look here ?
{
if (newkeys & KEY_SECONDARY_ATTACK)
{
if(ControllingShip[playerid] == 1)
{
ControllingShip[playerid] = 0;
new Float:X,Float:Y,Float:Z;
GetPlayerPos(playerid, X,Y,Z);
SetPlayerPos(playerid, X,Y+2,Z+6);
SetCameraBehindPlayer(playerid);
DestroyObject(Camera);
}
}

if (newkeys & KEY_FIRE)
{
if (!IsPlayerInAnyVehicle(playerid)) return 1;

if (GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return 1;

if (GetVehicleModel(GetPlayerVehicleID(playerid)) == 411)
{
AddVehicleComponent(GetPlayerVehicleID(playerid), 1010);
}
}

if((newkeys == KEY_JUMP && oldkeys == KEY_JUMP)&&(IsJumping[playerid] == 0))
{
if(PlayerInfo[playerid][pVip] >= 1)
IsJumping[playerid] = 1;
GetPlayerHealth(playerid, FirstHealth[playerid]);
SetPlayerVelocity(playerid,0.0,0.0,0.5);
SetTimerEx("JumpTimer", 5000, 0, "i", playerid);
}
else if(newkeys & KEY_JUMP)
{
if (MegaJump[playerid] == 1)
{
new Float:Jump[3];
GetPlayerVelocity(playerid, Jump[0], Jump[1], Jump[2]);
SetPlayerVelocity(playerid, Jump[0], Jump[1], Jump[2]+5);
}
}
if ( HOLDING( KEY_FIRE ) && GetPlayerState( playerid ) == PLAYER_STATE_DRIVER )
{
AddVehicleComponent( GetPlayerVehicleID( playerid ), 1010 );
}
if ( RELEASED( KEY_FIRE ) && GetPlayerState( playerid ) == PLAYER_STATE_DRIVER )
{
RemoveVehicleComponent( GetPlayerVehicleID( playerid ), 1010 );
}
if(IsPlayerInAnyVehicle(playerid))
{
if(newkeys & KEY_CROUCH)
{
new Float: P[ 4 ];
GetPlayerPos( playerid, P[ 0 ], P[ 1 ], P[ 2 ] );
GetVehicleZAngle( GetPlayerVehicleID( playerid ) , P[ 3 ]);
SetVehiclePos( GetPlayerVehicleID( playerid ), P[ 0 ], P[ 1 ], P[ 2 ] );
SetVehicleZAngle( GetPlayerVehicleID( playerid ), P[ 3 ] );
}
if(newkeys & KEY_YES)
{
new Float:x, Float:y, Float:z;
GetVehicleVelocity(GetPlayerVehicleID(playerid), x, y, z);
SetVehicleVelocity(GetPlayerVehicleID(playerid), x, y, z + 0.2);
}
else if(newkeys & KEY_SUBMISSION)
{
new Float:vx,Float:vy,Float:vz;
GetVehicleVelocity(GetPlayerVehicleID(playerid),vx ,vy,vz);
SetVehicleVelocity(GetPlayerVehicleID(playerid), vx * 1.8, vy *1.8, vz * 1.8);
}
}
if(newkeys & KEY_SECONDARY_ATTACK )
{
SetPlayerSpecialAction(playerid, 0);
}
if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
{
VehicleModel[playerid] = GetVehicleModel(GetPlayerVehicleID(playerid));
ShowGameTextForPlayer(playerid);
return 1;
}
if(newstate != PLAYER_STATE_DRIVER && (oldstate == PLAYER_STATE_DRIVER || oldstate == PLAYER_STATE_PASSENGER)) KillTimer(CFCTimer); //kills timer that checks for left vehicle if player exits vehicle
return 1;
}

You aren't ^^'

Mouiz
11/07/2015, 12:16 PM
i want to use this in OnPlayerKeyStateChange:

if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
{
VehicleModel[playerid] = GetVehicleModel(GetPlayerVehicleID(playerid));
ShowGameTextForPlayer(playerid);
return 1;
}
if(newstate != PLAYER_STATE_DRIVER && (oldstate == PLAYER_STATE_DRIVER || oldstate == PLAYER_STATE_PASSENGER)) KillTimer(CFCTimer);

KillerDVX
11/07/2015, 12:17 PM
So change it to this :

public OnPlayerStateChange(playerid, newstate, oldstate)

Mouiz
11/07/2015, 12:18 PM
As i saw :

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys, newstate,oldstate) // Look here ?
{
if (newkeys & KEY_SECONDARY_ATTACK)
{
if(ControllingShip[playerid] == 1)
{
ControllingShip[playerid] = 0;
new Float:X,Float:Y,Float:Z;
GetPlayerPos(playerid, X,Y,Z);
SetPlayerPos(playerid, X,Y+2,Z+6);
SetCameraBehindPlayer(playerid);
DestroyObject(Camera);
}
}

if (newkeys & KEY_FIRE)
{
if (!IsPlayerInAnyVehicle(playerid)) return 1;

if (GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return 1;

if (GetVehicleModel(GetPlayerVehicleID(playerid)) == 411)
{
AddVehicleComponent(GetPlayerVehicleID(playerid), 1010);
}
}

if((newkeys == KEY_JUMP && oldkeys == KEY_JUMP)&&(IsJumping[playerid] == 0))
{
if(PlayerInfo[playerid][pVip] >= 1)
IsJumping[playerid] = 1;
GetPlayerHealth(playerid, FirstHealth[playerid]);
SetPlayerVelocity(playerid,0.0,0.0,0.5);
SetTimerEx("JumpTimer", 5000, 0, "i", playerid);
}
else if(newkeys & KEY_JUMP)
{
if (MegaJump[playerid] == 1)
{
new Float:Jump[3];
GetPlayerVelocity(playerid, Jump[0], Jump[1], Jump[2]);
SetPlayerVelocity(playerid, Jump[0], Jump[1], Jump[2]+5);
}
}
if ( HOLDING( KEY_FIRE ) && GetPlayerState( playerid ) == PLAYER_STATE_DRIVER )
{
AddVehicleComponent( GetPlayerVehicleID( playerid ), 1010 );
}
if ( RELEASED( KEY_FIRE ) && GetPlayerState( playerid ) == PLAYER_STATE_DRIVER )
{
RemoveVehicleComponent( GetPlayerVehicleID( playerid ), 1010 );
}
if(IsPlayerInAnyVehicle(playerid))
{
if(newkeys & KEY_CROUCH)
{
new Float: P[ 4 ];
GetPlayerPos( playerid, P[ 0 ], P[ 1 ], P[ 2 ] );
GetVehicleZAngle( GetPlayerVehicleID( playerid ) , P[ 3 ]);
SetVehiclePos( GetPlayerVehicleID( playerid ), P[ 0 ], P[ 1 ], P[ 2 ] );
SetVehicleZAngle( GetPlayerVehicleID( playerid ), P[ 3 ] );
}
if(newkeys & KEY_YES)
{
new Float:x, Float:y, Float:z;
GetVehicleVelocity(GetPlayerVehicleID(playerid), x, y, z);
SetVehicleVelocity(GetPlayerVehicleID(playerid), x, y, z + 0.2);
}
else if(newkeys & KEY_SUBMISSION)
{
new Float:vx,Float:vy,Float:vz;
GetVehicleVelocity(GetPlayerVehicleID(playerid),vx ,vy,vz);
SetVehicleVelocity(GetPlayerVehicleID(playerid), vx * 1.8, vy *1.8, vz * 1.8);
}
}
if(newkeys & KEY_SECONDARY_ATTACK )
{
SetPlayerSpecialAction(playerid, 0);
}
if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
{
VehicleModel[playerid] = GetVehicleModel(GetPlayerVehicleID(playerid));
ShowGameTextForPlayer(playerid);
return 1;
}
if(newstate != PLAYER_STATE_DRIVER && (oldstate == PLAYER_STATE_DRIVER || oldstate == PLAYER_STATE_PASSENGER)) KillTimer(CFCTimer); //kills timer that checks for left vehicle if player exits vehicle
return 1;
}

You aren't ^^'

If i add ";" after on playerkeystatechange so i gives many errors

C:\Users\Mouiz\Desktop\FreeRoam\pawno\include\YSI\ y_va/impl.inc(538) : warning 219: local variable "x" shadows a variable at a preceding level
C:\Users\Mouiz\Desktop\FreeRoam\pawno\include\YSI\ y_va/impl.inc(538) : warning 219: local variable "y" shadows a variable at a preceding level
C:\Users\Mouiz\Desktop\FreeRoam\pawno\include\YSI\ y_va/impl.inc(543) : warning 219: local variable "x" shadows a variable at a preceding level
C:\Users\Mouiz\Desktop\FreeRoam\pawno\include\YSI\ y_va/impl.inc(543) : warning 219: local variable "y" shadows a variable at a preceding level
C:\Users\Mouiz\Desktop\FreeRoam\pawno\include\YSI\ y_inline.inc(606) : warning 219: local variable "y" shadows a variable at a preceding level
C:\Users\Mouiz\Desktop\FreeRoam\pawno\include\Spec Veh.inc(27) : warning 219: local variable "x" shadows a variable at a preceding level
C:\Users\Mouiz\Desktop\FreeRoam\pawno\include\Spec Veh.inc(27) : warning 219: local variable "y" shadows a variable at a preceding level
C:\Users\Mouiz\Desktop\FreeRoam\pawno\include\Spec Veh.inc(27) : warning 219: local variable "z" shadows a variable at a preceding level
C:\Users\Mouiz\Desktop\FreeRoam\pawno\include\Spec Veh.inc(51) : warning 219: local variable "x" shadows a variable at a preceding level
C:\Users\Mouiz\Desktop\FreeRoam\pawno\include\Spec Veh.inc(51) : warning 219: local variable "y" shadows a variable at a preceding level
C:\Users\Mouiz\Desktop\FreeRoam\pawno\include\Spec Veh.inc(51) : warning 219: local variable "z" shadows a variable at a preceding level
C:\Users\Mouiz\Desktop\FreeRoam\pawno\include\GetV ehicleColor.inc(37) : warning 219: local variable "x" shadows a variable at a preceding level
C:\Users\Mouiz\Desktop\FreeRoam\pawno\include\GetV ehicleColor.inc(37) : warning 219: local variable "y" shadows a variable at a preceding level
C:\Users\Mouiz\Desktop\FreeRoam\pawno\include\GetV ehicleColor.inc(37) : warning 219: local variable "z" shadows a variable at a preceding level
../include/gl_common.inc(164) : warning 219: local variable "x" shadows a variable at a preceding level
../include/gl_common.inc(164) : warning 219: local variable "y" shadows a variable at a preceding level
../include/gl_common.inc(164) : warning 219: local variable "z" shadows a variable at a preceding level
../include/gl_common.inc(177) : warning 219: local variable "x" shadows a variable at a preceding level
../include/gl_common.inc(177) : warning 219: local variable "y" shadows a variable at a preceding level
../include/gl_common.inc(177) : warning 219: local variable "z" shadows a variable at a preceding level
C:\Users\Mouiz\Desktop\FreeRoam\gamemodes\freeroam .pwn(177) : warning 219: local variable "x" shadows a variable at a preceding level
C:\Users\Mouiz\Desktop\FreeRoam\gamemodes\freeroam .pwn(178) : warning 219: local variable "y" shadows a variable at a preceding level
C:\Users\Mouiz\Desktop\FreeRoam\gamemodes\freeroam .pwn(179) : warning 219: local variable "z" shadows a variable at a preceding level
C:\Users\Mouiz\Desktop\FreeRoam\gamemodes\freeroam .pwn(731) : warning 219: local variable "x" shadows a variable at a preceding level
C:\Users\Mouiz\Desktop\FreeRoam\gamemodes\freeroam .pwn(731) : warning 219: local variable "y" shadows a variable at a preceding level
C:\Users\Mouiz\Desktop\FreeRoam\gamemodes\freeroam .pwn(731) : warning 219: local variable "z" shadows a variable at a preceding level
C:\Users\Mouiz\Desktop\FreeRoam\gamemodes\freeroam .pwn(745) : warning 219: local variable "X" shadows a variable at a preceding level
C:\Users\Mouiz\Desktop\FreeRoam\gamemodes\freeroam .pwn(746) : warning 219: local variable "Y" shadows a variable at a preceding level
C:\Users\Mouiz\Desktop\FreeRoam\gamemodes\freeroam .pwn(747) : warning 219: local variable "Z" shadows a variable at a preceding level
C:\Users\Mouiz\Desktop\FreeRoam\gamemodes\freeroam .pwn(1322) : warning 219: local variable "x" shadows a variable at a preceding level
C:\Users\Mouiz\Desktop\FreeRoam\gamemodes\freeroam .pwn(1323) : warning 219: local variable "y" shadows a variable at a preceding level
C:\Users\Mouiz\Desktop\FreeRoam\gamemodes\freeroam .pwn(1324) : warning 219: local variable "z" shadows a variable at a preceding level
C:\Users\Mouiz\Desktop\FreeRoam\gamemodes\freeroam .pwn(1424) : warning 219: local variable "X" shadows a variable at a preceding level
C:\Users\Mouiz\Desktop\FreeRoam\gamemodes\freeroam .pwn(1424) : warning 219: local variable "Y" shadows a variable at a preceding level
C:\Users\Mouiz\Desktop\FreeRoam\gamemodes\freeroam .pwn(1453) : warning 219: local variable "x" shadows a variable at a preceding level
C:\Users\Mouiz\Desktop\FreeRoam\gamemodes\freeroam .pwn(1888) : error 025: function heading differs from prototype
C:\Users\Mouiz\Desktop\FreeRoam\gamemodes\freeroam .pwn(1889) : error 055: start of function body without function header
C:\Users\Mouiz\Desktop\FreeRoam\gamemodes\freeroam .pwn(1890) : error 010: invalid function or declaration
C:\Users\Mouiz\Desktop\FreeRoam\gamemodes\freeroam .pwn(1892) : error 010: invalid function or declaration
C:\Users\Mouiz\Desktop\FreeRoam\gamemodes\freeroam .pwn(1896) : error 021: symbol already defined: "GetPlayerPos"
C:\Users\Mouiz\Desktop\FreeRoam\gamemodes\freeroam .pwn(1903) : error 010: invalid function or declaration
C:\Users\Mouiz\Desktop\FreeRoam\gamemodes\freeroam .pwn(1905) : error 010: invalid function or declaration
C:\Users\Mouiz\Desktop\FreeRoam\gamemodes\freeroam .pwn(1907) : error 010: invalid function or declaration
C:\Users\Mouiz\Desktop\FreeRoam\gamemodes\freeroam .pwn(1909) : error 010: invalid function or declaration
C:\Users\Mouiz\Desktop\FreeRoam\gamemodes\freeroam .pwn(1915) : error 010: invalid function or declaration
C:\Users\Mouiz\Desktop\FreeRoam\gamemodes\freeroam .pwn(1917) : error 010: invalid function or declaration
C:\Users\Mouiz\Desktop\FreeRoam\gamemodes\freeroam .pwn(1923) : error 010: invalid function or declaration
C:\Users\Mouiz\Desktop\FreeRoam\gamemodes\freeroam .pwn(1925) : error 010: invalid function or declaration
C:\Users\Mouiz\Desktop\FreeRoam\gamemodes\freeroam .pwn(1928) : error 021: symbol already defined: "GetPlayerVelocity"
C:\Users\Mouiz\Desktop\FreeRoam\gamemodes\freeroam .pwn(1932) : error 010: invalid function or declaration
C:\Users\Mouiz\Desktop\FreeRoam\gamemodes\freeroam .pwn(1936) : error 010: invalid function or declaration
C:\Users\Mouiz\Desktop\FreeRoam\gamemodes\freeroam .pwn(1940) : error 010: invalid function or declaration
C:\Users\Mouiz\Desktop\FreeRoam\gamemodes\freeroam .pwn(1942) : error 010: invalid function or declaration
C:\Users\Mouiz\Desktop\FreeRoam\gamemodes\freeroam .pwn(1945) : error 021: symbol already defined: "GetPlayerPos"
C:\Users\Mouiz\Desktop\FreeRoam\gamemodes\freeroam .pwn(1950) : error 010: invalid function or declaration
C:\Users\Mouiz\Desktop\FreeRoam\gamemodes\freeroam .pwn(1953) : error 021: symbol already defined: "GetVehicleVelocity"
C:\Users\Mouiz\Desktop\FreeRoam\gamemodes\freeroam .pwn(1956) : error 010: invalid function or declaration
C:\Users\Mouiz\Desktop\FreeRoam\gamemodes\freeroam .pwn(1959) : error 021: symbol already defined: "GetVehicleVelocity"
C:\Users\Mouiz\Desktop\FreeRoam\gamemodes\freeroam .pwn(1963) : error 010: invalid function or declaration
C:\Users\Mouiz\Desktop\FreeRoam\gamemodes\freeroam .pwn(1967) : error 010: invalid function or declaration
C:\Users\Mouiz\Desktop\FreeRoam\gamemodes\freeroam .pwn(1971) : error 010: invalid function or declaration

Compilation aborted.Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase


26 Errors.

Mouiz
11/07/2015, 12:21 PM
So change it to this :

public OnPlayerStateChange(playerid, newstate, oldstate)

thanks