Flip/Speedboost/Jump with car
#9

Quote:
Originally Posted by Wesley221
Посмотреть сообщение
pawn Код:
public OnPlayerKeyStateChange(playerid,newkeys,oldkeys)
{
    if(IsPlayerInAnyVehicle(playerid))
    {
        if(newkeys &= 2)
        {
            if( GetPlayerState( playerid ) != PLAYER_STATE_DRIVER ) return SendClientMessage(playerid, -1, "You cant use this since youre not the driver!"); // if the playerstate doesnt equals to 2, it sends him the message
            new Float:ZAngle,Float:X,Float:Y,Float:Z,vehicleid;
            vehicleid = GetPlayerVehicleID(playerid);
            GetVehiclePos(vehicleid,X,Y,Z);
            GetVehicleZAngle(vehicleid,ZAngle);
            SetVehicleZAngle(vehicleid,ZAngle);
            SetVehiclePos(vehicleid,X,Y,Z+2);
        }
    }
    return 1;
}
Also, Thanks Wesley221 for the flip part! All works fine with it.

Question:

I want to add a ChaseCar, this is the FS
pawn Код:
#include <a_samp> //includes a_samp

new AllCars[93] =
{
400,401,402,404,405,410,411,412,415,418,419,420,421,422,424,426,429,434,436,
438,439,442,445,451,458,466,467,470,474,475,477,478,480,480,480,480,489,490,
491,492,494,496,500,501,502,503,504,505,506,507,516,517,518,526,527,529,533,
534,535,536,540,541,542,543,545,546,547,549,550,551,555,558,559,560,561,562,
565,566,567,575,576,580,585,587,589,596,597,598,600,602,603,604,605,
}; //defines all the cars in game

new Float:x = 2324.3391; //x position
new Float:y = -1270.5941; //y position
new Float:z = 22.1586; //z position
new Float:rot = 180.6980; //rotation

new ccar; //stores the car
forward ccc(); //forward ccc

main()
{
    print("ChaseCar loaded!"); //prints ClaseCar loaded!
}

public OnFilterScriptInit()
{
    ccar = AddStaticVehicle(562,x,y,z,rot,122,1); // ccar
    SetTimer("ccc", 500, 1); //sets the timer
   
    for(new i=0; i<MAX_VEHICLES; i++)  //loop
    {
        if(i == ccar) //if i == ccar
        {
            SetVehicleNumberPlate(i, "ChaseMe"); //sets the cars number plate
            SetVehicleToRespawn(i); //respawns it (VERY IMPORTANT!!!)
        }
    }
    return 1;
}

public OnFilterScriptExit()
{
    DestroyVehicle(ccar); //destroys the car
    return 1;
}

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if(vehicleid == ccar) //if vehicleid == ccar
    {
        new name[MAX_PLAYER_NAME], string[44]; //defines name and string
        GetPlayerName(playerid, name, sizeof(name)); //gets the players name
        format(string, sizeof(string), "%s has taken the ChaseCar!",name); //formats the message
        SendClientMessageToAll(0xFF0000FF, string); //sends the message
    }
    return 1;
}

public OnPlayerExitVehicle(playerid, vehicleid)
{
    if(vehicleid == ccar) //if vehicleid == ccar
    {
        new name[MAX_PLAYER_NAME], string[44]; //defines name and string
        GetPlayerName(playerid, name, sizeof(name)); //gets the players name
        format(string, sizeof(string), "%s has left the ChaseCar!",name); //formats the message
        SendClientMessageToAll(0xFF0000FF, string); //sends the message
    }
    return 1;
}

public OnVehicleSpawn(vehicleid)
{
    if(vehicleid == ccar)
    {
        ChangeVehiclePaintjob(vehicleid,0); // paint job
        AddVehicleComponent(vehicleid, 1038); // roof
        AddVehicleComponent(vehicleid, 1079); // rim
        AddVehicleComponent(vehicleid, 1037); // exhaust
        AddVehicleComponent(vehicleid, 1041); // side
        AddVehicleComponent(vehicleid, 1153); // front
        AddVehicleComponent(vehicleid, 1148); // rear
        AddVehicleComponent(vehicleid, 1139); // Spoiler
        AddVehicleComponent(vehicleid, 1010); // Nitrous
        SendClientMessageToAll(0xFF0000FF, "The ChaseCar Respawned!!!"); //message
    }
    return 1;
}

public ccc() //public
{
    for(new i=0; i < MAX_PLAYERS; i++) //loop
    {
        if(IsPlayerInCar(i)) //if player is in car
        {
            if(GetPlayerVehicleID(i) == ccar) //if player car == ccar
            {
                GivePlayerMoney(i, 500); //gives player money
            }
        }
    }
}

stock IsPlayerInCar(playerid) //function
{
    new vehicleid = GetPlayerVehicleID(playerid); //gets the vehicle id
    if(!IsPlayerInAnyVehicle(playerid)) return 0; //if player aint in cat, return 0;
    for(new i = 0; i < 93; i++) //loop
    {
        if(GetVehicleModel(vehicleid) == AllCars[i]) //if the car is a car in allcars
        {
            return 1; //returns 1
        }
    }
    return 0; //returns 0
}
How can I cancel again the speedboost/jumpcar/flip while you are driving the ChaseCar?
Reply


Messages In This Thread
Flip/Speedboost/Jump with car - by Kostas' - 10.10.2011, 17:42
Re: Flip/Speedboost/Jump with car - by Zonoya - 10.10.2011, 17:45
Re: Flip/Speedboost/Jump with car - by [CrC]reinixx - 10.10.2011, 18:26
Re: Flip/Speedboost/Jump with car - by Elorreli - 10.10.2011, 18:28
Re: Flip/Speedboost/Jump with car - by Kostas' - 10.10.2011, 19:15
Re: Flip/Speedboost/Jump with car - by Elorreli - 10.10.2011, 23:59
Re: Flip/Speedboost/Jump with car - by Kostas' - 11.10.2011, 06:52
Re: Flip/Speedboost/Jump with car - by Wesley221 - 11.10.2011, 06:57
Re: Flip/Speedboost/Jump with car - by Kostas' - 11.10.2011, 08:38
Re: Flip/Speedboost/Jump with car - by Wesley221 - 11.10.2011, 16:51

Forum Jump:


Users browsing this thread: 2 Guest(s)