Combine 2 scripts
#1

Add this script...

pawn Код:
if (PRESSED(KEY_FIRE))
        {
            AddVehicleComponent(GetPlayerVehicleID(playerid),1010);
        }
    if(newkeys & KEY_SUBMISSION)
    {
    if (IsPlayerInAnyVehicle(playerid))
        {
            if((GetPlayerVehicleID(playerid) == 520) || (GetPlayerVehicleID(playerid) == 425) || (GetPlayerVehicleID(playerid) == 464)) {
        return 1;
        }
            else {
            new Float:vx, Float:vy, Float:vz;
            GetVehicleVelocity(GetPlayerVehicleID(playerid), vx, vy, vz);
            SetVehicleVelocity(GetPlayerVehicleID(playerid) ,vx*2,vy*2 ,vz*2);
            }
        }
    }
    return 1;
}
In here..
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(newkeys == KEY_SECONDARY_ATTACK)
    {
        if(!IsPlayerInAnyVehicle(playerid))
        {
            new Float:x, Float:y, Float:z, vehicle;
            GetPlayerPos(playerid, x, y, z);
            GetVehicleWithinDistance(playerid, x, y, z, 20.0, vehicle);
            if(IsVehicleRc(vehicle))
            {
                PutPlayerInVehicle(playerid, vehicle, 0);
            }
        }
        else {
            new vehicleID = GetPlayerVehicleID(playerid);
            if(IsVehicleRc(vehicleID) || GetVehicleModel(vehicleID) == RC_CAM){
                if(GetVehicleModel(vehicleID) != D_TRAM){
                    new Float:x, Float:y, Float:z;
                    GetPlayerPos(playerid, x, y, z);
                    SetPlayerPos(playerid, x+0.5, y, z+1.0);
                }
            }
        }
    }
    if(!gPlayerUsingLoopingAnim[playerid]) return;
    if(IsKeyJustDown(KEY_SECONDARY_ATTACK,newkeys,oldkeys))
    {
        StopLoopingAnim(playerid);
        TextDrawHideForPlayer(playerid,txtAnimHelper);
    }
}
Coz i tried and it gives me lot of warnings also, not responding..
Reply
#2

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(newkeys == KEY_SECONDARY_ATTACK)
    {
        if(!IsPlayerInAnyVehicle(playerid))
        {
            new Float:x, Float:y, Float:z, vehicle;
            GetPlayerPos(playerid, x, y, z);
            GetVehicleWithinDistance(playerid, x, y, z, 20.0, vehicle);
            if(IsVehicleRc(vehicle))
            {
                PutPlayerInVehicle(playerid, vehicle, 0);
            }
        }
        else {
            new vehicleID = GetPlayerVehicleID(playerid);
            if(IsVehicleRc(vehicleID) || GetVehicleModel(vehicleID) == RC_CAM){
                if(GetVehicleModel(vehicleID) != D_TRAM){
                    new Float:x, Float:y, Float:z;
                    GetPlayerPos(playerid, x, y, z);
                    SetPlayerPos(playerid, x+0.5, y, z+1.0);
                }
            }
        }
    }
    if(!gPlayerUsingLoopingAnim[playerid]) return;
    if(IsKeyJustDown(KEY_SECONDARY_ATTACK,newkeys,oldkeys))
    {
        StopLoopingAnim(playerid);
        TextDrawHideForPlayer(playerid,txtAnimHelper);
    }
    if (PRESSED(KEY_FIRE))
        {
            AddVehicleComponent(GetPlayerVehicleID(playerid),1010);
        }
    if(newkeys & KEY_SUBMISSION)
    {
    if (IsPlayerInAnyVehicle(playerid))
        {
            if((GetPlayerVehicleID(playerid) == 520) || (GetPlayerVehicleID(playerid) == 425) || (GetPlayerVehicleID(playerid) == 464)) {
        return 1;
        }
            else {
            new Float:vx, Float:vy, Float:vz;
            GetVehicleVelocity(GetPlayerVehicleID(playerid), vx, vy, vz);
            SetVehicleVelocity(GetPlayerVehicleID(playerid) ,vx*2,vy*2 ,vz*2);
            }
        }
    }
    return 1;
}
Reply
#3

Quote:
Originally Posted by SuperViper
Посмотреть сообщение
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(newkeys == KEY_SECONDARY_ATTACK)
    {
        if(!IsPlayerInAnyVehicle(playerid))
        {
            new Float:x, Float:y, Float:z, vehicle;
            GetPlayerPos(playerid, x, y, z);
            GetVehicleWithinDistance(playerid, x, y, z, 20.0, vehicle);
            if(IsVehicleRc(vehicle))
            {
                PutPlayerInVehicle(playerid, vehicle, 0);
            }
        }
        else {
            new vehicleID = GetPlayerVehicleID(playerid);
            if(IsVehicleRc(vehicleID) || GetVehicleModel(vehicleID) == RC_CAM){
                if(GetVehicleModel(vehicleID) != D_TRAM){
                    new Float:x, Float:y, Float:z;
                    GetPlayerPos(playerid, x, y, z);
                    SetPlayerPos(playerid, x+0.5, y, z+1.0);
                }
            }
        }
    }
    if(!gPlayerUsingLoopingAnim[playerid]) return;
    if(IsKeyJustDown(KEY_SECONDARY_ATTACK,newkeys,oldkeys))
    {
        StopLoopingAnim(playerid);
        TextDrawHideForPlayer(playerid,txtAnimHelper);
    }
    if (PRESSED(KEY_FIRE))
        {
            AddVehicleComponent(GetPlayerVehicleID(playerid),1010);
        }
    if(newkeys & KEY_SUBMISSION)
    {
    if (IsPlayerInAnyVehicle(playerid))
        {
            if((GetPlayerVehicleID(playerid) == 520) || (GetPlayerVehicleID(playerid) == 425) || (GetPlayerVehicleID(playerid) == 464)) {
        return 1;
        }
            else {
            new Float:vx, Float:vy, Float:vz;
            GetVehicleVelocity(GetPlayerVehicleID(playerid), vx, vy, vz);
            SetVehicleVelocity(GetPlayerVehicleID(playerid) ,vx*2,vy*2 ,vz*2);
            }
        }
    }
    return 1;
}
Thanks but Im getting this warnings:


Код:
(939) : warning 209: function "OnPlayerKeyStateChange" should return a value
(954) : error 078: function uses both "return" and "return <value>"
(963) : error 078: function uses both "return" and "return <value>"
Lines:
Код:
    if(!gPlayerUsingLoopingAnim[playerid]) return;
    if(IsKeyJustDown(KEY_SECONDARY_ATTACK,newkeys,oldkeys))
    {
        StopLoopingAnim(playerid);
        TextDrawHideForPlayer(playerid,txtAnimHelper);
    }
    if (PRESSED(KEY_FIRE))
        {
            AddVehicleComponent(GetPlayerVehicleID(playerid),1010);
        }
    if(newkeys & KEY_SUBMISSION)
    {
    if (IsPlayerInAnyVehicle(playerid))
        {
            if((GetPlayerVehicleID(playerid) == 520) || (GetPlayerVehicleID(playerid) == 425) || (GetPlayerVehicleID(playerid) == 464)) {
        return 1;
        }
            else {
            new Float:vx, Float:vy, Float:vz;
            GetVehicleVelocity(GetPlayerVehicleID(playerid), vx, vy, vz);
            SetVehicleVelocity(GetPlayerVehicleID(playerid) ,vx*2,vy*2 ,vz*2);
            }
        }
    }
    return 1;
}
Reply
#4

that's because you return; and return 1; in the same function.

this is a sa-mp callback, therefore you shouldn't be returning without either 1 or 0 anyway.
Reply
#5

Quote:
Originally Posted by Rob_Maate
Посмотреть сообщение
that's because you return; and return 1; in the same function.

this is a sa-mp callback, therefore you shouldn't be returning without either 1 or 0 anyway.
Well after removing both returns then compile No warnings, but when im in-game it's not working.. zzz.
Reply
#6

I meant change 'return;' to 'return 1;' not delete them.
Reply
#7

thanks but still not working ingame.
Reply
#8

Try This:
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(newkeys == KEY_SECONDARY_ATTACK)
    {
        if(!IsPlayerInAnyVehicle(playerid))
        {
            new Float:x, Float:y, Float:z, vehicle;
            GetPlayerPos(playerid, x, y, z);
            GetVehicleWithinDistance(playerid, x, y, z, 20.0, vehicle);
            if(IsVehicleRc(vehicle))
            {
                PutPlayerInVehicle(playerid, vehicle, 0);
            }
        }
        else
        {
            new vehicleID = GetPlayerVehicleID(playerid);
            if(IsVehicleRc(vehicleID) || GetVehicleModel(vehicleID) == RC_CAM)
            {
                if(GetVehicleModel(vehicleID) != D_TRAM)
                {
                    new Float:x, Float:y, Float:z;
                    GetPlayerPos(playerid, x, y, z);
                    SetPlayerPos(playerid, x+0.5, y, z+1.0);
                }
            }
        }
    }
    if(!gPlayerUsingLoopingAnim[playerid]) return 1;
    if(IsKeyJustDown(KEY_SECONDARY_ATTACK,newkeys,oldkeys))
    {
        StopLoopingAnim(playerid);
        TextDrawHideForPlayer(playerid,txtAnimHelper);
    }
    if(PRESSED(KEY_FIRE)) AddVehicleComponent(GetPlayerVehicleID(playerid),1010);
    if(newkeys & KEY_SUBMISSION)
    {
        if(IsPlayerInAnyVehicle(playerid))
        {
            if((GetPlayerVehicleID(playerid) == 520) || (GetPlayerVehicleID(playerid) == 425) || (GetPlayerVehicleID(playerid) == 464)) return 1;
            else
            {
                new Float:vx, Float:vy, Float:vz;
                GetVehicleVelocity(GetPlayerVehicleID(playerid), vx, vy, vz);
                SetVehicleVelocity(GetPlayerVehicleID(playerid) ,vx*2,vy*2 ,vz*2);
            }
        }
    }
    return 1;
}
Reply
#9

Quote:
Originally Posted by Andi_Evandy
Посмотреть сообщение
Try This:
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(newkeys == KEY_SECONDARY_ATTACK)
    {
        if(!IsPlayerInAnyVehicle(playerid))
        {
            new Float:x, Float:y, Float:z, vehicle;
            GetPlayerPos(playerid, x, y, z);
            GetVehicleWithinDistance(playerid, x, y, z, 20.0, vehicle);
            if(IsVehicleRc(vehicle))
            {
                PutPlayerInVehicle(playerid, vehicle, 0);
            }
        }
        else
        {
            new vehicleID = GetPlayerVehicleID(playerid);
            if(IsVehicleRc(vehicleID) || GetVehicleModel(vehicleID) == RC_CAM)
            {
                if(GetVehicleModel(vehicleID) != D_TRAM)
                {
                    new Float:x, Float:y, Float:z;
                    GetPlayerPos(playerid, x, y, z);
                    SetPlayerPos(playerid, x+0.5, y, z+1.0);
                }
            }
        }
    }
    if(!gPlayerUsingLoopingAnim[playerid]) return 1;
    if(IsKeyJustDown(KEY_SECONDARY_ATTACK,newkeys,oldkeys))
    {
        StopLoopingAnim(playerid);
        TextDrawHideForPlayer(playerid,txtAnimHelper);
    }
    if(PRESSED(KEY_FIRE)) AddVehicleComponent(GetPlayerVehicleID(playerid),1010);
    if(newkeys & KEY_SUBMISSION)
    {
        if(IsPlayerInAnyVehicle(playerid))
        {
            if((GetPlayerVehicleID(playerid) == 520) || (GetPlayerVehicleID(playerid) == 425) || (GetPlayerVehicleID(playerid) == 464)) return 1;
            else
            {
                new Float:vx, Float:vy, Float:vz;
                GetVehicleVelocity(GetPlayerVehicleID(playerid), vx, vy, vz);
                SetVehicleVelocity(GetPlayerVehicleID(playerid) ,vx*2,vy*2 ,vz*2);
            }
        }
    }
    return 1;
}
Sorry man still it's not working... No warning after compiling.


Anyway I have this on top of the script:

Код:
#define PRESSED(%0) \
(((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)