Mechanic.
#1

Well I'm looking for a mechanic job, but when you type /repairvehicle it shows you a textdraw of five seconds and does an anim to look like he's fixing the car. Once the five second timer is done, the vehicle will be fixed.

Rep if you help.
Reply
#2

We can't help you unless you provide the code.
Reply
#3

Quote:
Originally Posted by Manyula
View Post
We can't help you unless you provide the code.
There is no code. I'm asking on how to do it.
Reply
#4

I'm not going to give you any code since this is really simple. Try this:

1. First, you check in the CMD whether there is a vehicle in range of the point the player is currently at.
2. Then you start a Timer, preferrably SetTimerEx and start the animation.
3. You create the timer public and forward it.
4. In the timer public, you clear all animations and set the vehicles health to whatever you want.

EDIT: This is what I found.
pawn Code:
public GetClosestVehicleFromPlayer(playerid)
{
    new Float:dis = 99999999.0;
    new veh = -1;
    new Float:x, Float:y, Float:z;
    GetPlayerPos(playerid, x, y, z);
    for(new i = 1; i < MAX_VEHICLES; i++)
    {
        new Float:distance = GetVehicleDistanceFromPoint(i, x, y, z);
        if(distance < dis)
        {
            dis = distance;
            veh = i;
        }
    }
    return veh;
}
Reply
#5

I didn't understand much, but thanks. Rep
Reply
#6

:/ ..... There are some filterscripts u can use them? or search for a tutorial?
It's not hard..
Reply
#7

Quote:
Originally Posted by Rudy_
View Post
:/ ..... There are some filterscripts u can use them? or search for a tutorial?
It's not hard..
I know, but I'd really just love to learn as it could help me with future scripting.
Reply
#8

Not tested and Plus some parts are from '******/Other script'
pawn Code:
// This is a comment
// uncomment the line below if you want to write a filterscript
//#define FILTERSCRIPT

#include <a_samp>
#include <Zcmd>

new Mechanic[MAX_PLAYERS];
new vehid;

encode_tires(tire1, tire2, tire3, tire4) return tire1 | (tire2 << 1) | (tire3 << 2) | (tire4 << 3);
encode_panels(flp, frp, rlp, rrp, windshield, front_bumper, rear_bumper)
{
    return flp | (frp << 4) | (rlp << 8) | (rrp << 12) | (windshield << 16) | (front_bumper << 20) | (rear_bumper << 24);
}
encode_doors(bonnet, boot, driver_door, passenger_door, behind_driver_door, behind_passenger_door)
{
    #pragma unused behind_driver_door
    #pragma unused behind_passenger_door
    return bonnet | (boot << 8) | (driver_door << 16) | (passenger_door << 24);
}
encode_lights(light1, light2, light3, light4)
{
    return light1 | (light2 << 1) | (light3 << 2) | (light4 << 3);
}


#if defined FILTERSCRIPT

public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    print(" Blank Filterscript by your name here");
    print("--------------------------------------\n");
    return 1;
}

public OnFilterScriptExit()
{
    return 1;
}

#else

main()
{
    print("\n----------------------------------");
    print(" Blank Gamemode by your name here");
    print("----------------------------------\n");
}

#endif

public OnGameModeInit()
{
    // Don't use these lines if it's a filterscript
    SetGameModeText("Blank Script");
    AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
    return 1;
}

public OnGameModeExit()
{
    return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
    SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
    SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
    SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
    return 1;
}

public OnPlayerConnect(playerid)
{
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    return 1;
}

public OnPlayerSpawn(playerid)
{
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    return 1;
}

public OnVehicleSpawn(vehicleid)
{
    return 1;
}

public OnVehicleDeath(vehicleid, killerid)
{
    return 1;
}

public OnPlayerText(playerid, text[])
{
    return 1;
}


public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    return 1;
}

public OnPlayerExitVehicle(playerid, vehicleid)
{
    return 1;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
    return 1;
}

public OnPlayerEnterCheckpoint(playerid)
{
    return 1;
}

public OnPlayerLeaveCheckpoint(playerid)
{
    return 1;
}

public OnPlayerEnterRaceCheckpoint(playerid)
{
    return 1;
}

public OnPlayerLeaveRaceCheckpoint(playerid)
{
    return 1;
}

public OnRconCommand(cmd[])
{
    return 1;
}

public OnPlayerRequestSpawn(playerid)
{
    return 1;
}

public OnObjectMoved(objectid)
{
    return 1;
}

public OnPlayerObjectMoved(playerid, objectid)
{
    return 1;
}

public OnPlayerPickUpPickup(playerid, pickupid)
{
    return 1;
}

public OnVehicleMod(playerid, vehicleid, componentid)
{
    return 1;
}

public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
{
    return 1;
}

public OnVehicleRespray(playerid, vehicleid, color1, color2)
{
    return 1;
}

public OnPlayerSelectedMenuRow(playerid, row)
{
    return 1;
}

public OnPlayerExitedMenu(playerid)
{
    return 1;
}

public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
{
    return 1;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    return 1;
}

public OnRconLoginAttempt(ip[], password[], success)
{
    return 1;
}

public OnPlayerUpdate(playerid)
{
    return 1;
}

public OnPlayerStreamIn(playerid, forplayerid)
{
    return 1;
}

public OnPlayerStreamOut(playerid, forplayerid)
{
    return 1;
}

public OnVehicleStreamIn(vehicleid, forplayerid)
{
    return 1;
}

public OnVehicleStreamOut(vehicleid, forplayerid)
{
    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    return 1;
}

public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
    return 1;
}

forward GetClosestVehicleFromPlayer(playerid);
public GetClosestVehicleFromPlayer(playerid)
{
    new Float:dis = 99999999.0;
    new veh = -1;
    new Float:x, Float:y, Float:z;
    GetPlayerPos(playerid, x, y, z);
    for(new i = 1; i < MAX_VEHICLES; i++)
    {
        new Float:distance = GetVehicleDistanceFromPoint(i, x, y, z);
        if(distance < dis)
        {
            dis = distance;
            veh = i;
        }
    }
    return veh;
}

CMD:mechanic(playerid, params[])
{
    if(Mechanic[playerid] != 1) return Mechanic[playerid] = 1;
    return 1;
}

CMD:repairvehicle(playerid, params[])
{
    if(Mechanic[playerid] == 1)
    {
        GetClosestVehicleFromPlayer(playerid);
        new panels,doors,lights,tires;
        vehid = GetPlayerVehicleID(playerid);
        tires = encode_tires(0, 0, 0, 0); // fix all tires
        panels = encode_panels(0, 0, 0, 0, 0, 0, 0); // fix all panels
        doors = encode_doors(0, 0, 0, 0, 0, 0); // fix all doors
        lights = encode_lights(0, 0, 0, 0); // fix all lights
        UpdateVehicleDamageStatus(vehid, panels, doors, lights, tires);
        vehid = GetPlayerVehicleID(playerid);
        SetVehicleHealth(vehid, 1000.0);
        SendClientMessage(playerid, -1, "vehicle successfully repaired");
    }
    else SendClientMessage(playerid, -1, "You are not a Mechanic");
    return 1;
}
Reply
#9

I think that filterscript causes even more confusion.^^

Let's start small: Are you familiar with the basics of scripting in PAWN?

Edit: This might come in handy: https://sampforum.blast.hk/showthread.php?tid=307637
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)