Private cars system
#1

Hi guys.
I have an filterscript to registering for own vehicles:
pawn Код:
#include <a_samp>
#include <zcmd>
#include <sscanf2>
#include <dof2>

#define ORANGE          "{FF8000}"
#define L_GREEN         "{00FF00}"
#define GREEN           "{008000}"
#define YELLOW          "{DDDD22}"
#define WHITE           "{FFFFFF}"
#define BLUE            "{0435FB}"
#define L_BLUE          "{0080FF}"
#define L_YELLOW        "{FFFF80}"
#define L_VIOLET        "{8080FF}"
#define VIOLET          "{8000FF}"
#define L_RED           "{FF0000}"
#define RED             "{800000}"

#define COLOR_ORANGE    0xFF8000C8
#define COLOR_LGREEN    0x00FF00C8
#define COLOR_GREEN     0x008000C8
#define COLOR_LYELLOW   0xFFFF80C8
#define COLOR_YELLOW    0xDDDD22C8
#define COLOR_WHITE     0xFFFFFFC8
#define COLOR_BLACK     0x000000C8
#define COLOR_LBLUE     0x0080FFC8
#define COLOR_BLUE      0x0435FBC8
#define COLOR_LVIOLET   0x8080FFC8
#define COLOR_VIOLET    0x8000FFC8
#define COLOR_LRED      0xFF0000C8
#define COLOR_RED       0x800000C8

#define DIALOG_PCAR 872
#define DIALOG_CHANGEMODEL 9754

new CarList[212][20] =
{
    {"Landstalker"},
    {"Bravura"},
    {"Buffalo"},
    {"Linerunner"},
    {"Perrenial"},
    {"Sentinel"},
    {"Dumper"},
    {"Fire Truck"},
    {"Trashmaster"},
    {"Stretch"},
    {"Manana"},
    {"Infernus"},
    {"Voodoo"},
    {"Pony"},
    {"Mule"},
    {"Cheetah"},
    {"Ambulance"},
    {"Leviathan"},
    {"Moonbeam"},
    {"Esperanto"},
    {"Taxi"},
    {"Washington"},
    {"Bobcat"},
    {"Mr Whoopee"},
    {"BF Injection"},
    {"Hunter"},
    {"Premier"},
    {"Enforcer"},
    {"Securicar"},
    {"Banshee"},
    {"Predator"},
    {"Bus"},
    {"Rhino"},
    {"Barracks"},
    {"Hotknife"},
    {"Trailer 1"},
    {"Previon"},
    {"Coach"},
    {"Cabbie"},
    {"Stallion"},
    {"Rumpo"},
    {"RC Bandit"},
    {"Romero"},
    {"Packer"},
    {"Monster"},
    {"Admiral"},
    {"Squalo"},
    {"Seaspar"},
    {"Pizzaboy"},
    {"Tram"},
    {"Trailer 2"},
    {"Turismo"},
    {"Speeder"},
    {"Reefer"},
    {"Tropic"},
    {"Flatbed"},
    {"Yankee"},
    {"Caddy"},
    {"Solair"},
    {"Berkley's RC Van"},
    {"Skimmer"},
    {"PCJ-600"},
    {"Faggio"},
    {"Freeway"},
    {"RC Baron"},
    {"RC Raider"},
    {"Glendale"},
    {"Oceanic"},
    {"Sanchez"},
    {"Sparroww"},
    {"Patriot"},
    {"Quad"},
    {"Coastguard"},
    {"Dinghy"},
    {"Hermes"},
    {"Sabre"},
    {"Rustler"},
    {"ZR-350"},
    {"Walton"},
    {"Regina"},
    {"Comet"},
    {"BMX"},
    {"Burrito"},
    {"Camper"},
    {"Marquis"},
    {"Baggage"},
    {"Dozer"},
    {"Maverick"},
    {"VCNMaverick"},
    {"Rancher"},
    {"FBI Rancher"},
    {"Virgo"},
    {"Greenwood"},
    {"Jetmax"},
    {"Hotring"},
    {"Sandking"},
    {"Blista Compact"},
    {"Police Maverick"},
    {"Boxville"},
    {"Benson"},
    {"Mesa"},
    {"RC Goblin"},
    {"Hotring A"},
    {"Hotring B"},
    {"Bloodring Banger"},
    {"Rancher"},
    {"Super GT"},
    {"Elegant"},
    {"Journey"},
    {"Bike"},
    {"Mountain Bike"},
    {"Beagle"},
    {"Cropdust"},
    {"Stunt"},
    {"Tanker"},
    {"Roadtrain"},
    {"Nebula"},
    {"Majestic"},
    {"Buccaneer"},
    {"Shamal"},
    {"Hydra"},
    {"FCR-900"},
    {"NRG-500"},
    {"HPV1000"},
    {"Cement Truck"},
    {"Tow Truck"},
    {"Fortune"},
    {"Cadrona"},
    {"FBI Truck"},
    {"Willard"},
    {"Forklift"},
    {"Tractor"},
    {"Combine"},
    {"Feltzer"},
    {"Remington"},
    {"Slamvan"},
    {"Blade"},
    {"Freight"},
    {"Streak"},
    {"Vortex"},
    {"Vincent"},
    {"Bullet"},
    {"Clover"},
    {"Sadler"},
    {"Firetruck LA"},
    {"Hustler"},
    {"Intruder"},
    {"Primo"},
    {"Cargobob"},
    {"Tampa"},
    {"Sunrise"},
    {"Merit"},
    {"Utility"},
    {"Nevada"},
    {"Yosemite"},
    {"Windsor"},
    {"Monster A"},
    {"Monster B"},
    {"Uranus"},
    {"Jester"},
    {"Sultan"},
    {"Stratum"},
    {"Elegy"},
    {"Raindance"},
    {"RC Tiger"},
    {"Flash"},
    {"Tahoma"},
    {"Savanna"},
    {"Bandito"},
    {"Freight Flat"},
    {"Streak Carriage"},
    {"Kart"},
    {"Mower"},
    {"Duneride"},
    {"Sweeper"},
    {"Broadway"},
    {"Tornado"},
    {"AT-400"},
    {"DFT-30"},
    {"Huntley"},
    {"Stafford"},
    {"BF-400"},
    {"Newsvan"},
    {"Tug"},
    {"Trailer 3"},
    {"Emperor"},
    {"Wayfarer"},
    {"Euros"},
    {"Hotdog"},
    {"Club"},
    {"Freight Carriage"},
    {"Trailer 3"},
    {"Andromada"},
    {"Dodo"},
    {"RC Cam"},
    {"Launch"},
    {"LSPD"},
    {"SFPD"},
    {"LVPD"},
    {"Police Ranger"},
    {"Picador"},
    {"SWAT Van"},
    {"Alpha"},
    {"Phoenix"},
    {"Glendale"},
    {"Sadler"},
    {"Luggage Trailer A"},
    {"Luggage Trailer B"},
    {"Stair Trailer"},
    {"Boxville"},
    {"Farm Plow"},
    {"Utility Trailer"}
};

new Type, Amount;

public OnFilterScriptInit()
{
    print("-------------------------------------------------");
    print("----- Dynamiczny system prywatnych pojazdуw -----");
    print("------------------ by CombaT --------------------");
    print("-------------------------------------------------");
   
    AntiDeAMX();
    return 1;
}

#define SCM SendClientMessage
#define Loop(%1,%2) for(new %1; %1 < %2; %1++)
#define MAX_GRACZY 60

enum pInfo
{
    CarID,
    Tim,
    C[2],
    bool:Have,
}

new Player[MAX_GRACZY][pInfo];
new Text3D:vehicle3Dtext[1000];
new Float:Dist[1000];
new bool:IsPriv[1000];

public OnFilterScriptExit()
{
    Loop(i, 1000)
    {
        if(i <= MAX_GRACZY)
        {
            Player[i][CarID] = -1;
            KillTimer(Player[i][Tim]);
            Player[i][Have] = false;
        }
        Dist[i] = 0.0;
        IsPriv[i] = false;
        Delete3DTextLabel(Text3D:vehicle3Dtext[i]);
    }
    DOF2_Exit();
    return 1;
}

public OnPlayerConnect(playerid)
{
    new file[64];

    Player[playerid][CarID] = -1;
    Player[playerid][Have] = false;

    format(file, 64, "/Privcars/%s.ini", PlayerName(playerid));
    if(DOF2_FileExists(file))
    {
        new Float:pos[4], carid, s[128];

        pos[0] = DOF2_GetFloat(file, "X");
        pos[1] = DOF2_GetFloat(file, "Y");
        pos[2] = DOF2_GetFloat(file, "Z");
        pos[3] = DOF2_GetFloat(file, "A");
        carid = DOF2_GetInt(file, "CarID");
        Player[playerid][C][0] = DOF2_GetInt(file, "Color0");
        Player[playerid][C][1] = DOF2_GetInt(file, "Color1");
       
        Player[playerid][CarID] = CreateVehicle(carid, pos[0], pos[1], pos[2], pos[3], Player[playerid][C][0], Player[playerid][C][1], -1);
        SCM(playerid, COLOR_WHITE, " *** Posiadasz "ORANGE"prywatny pojazd! "WHITE"Został on przywrуcony na miejsce przed Twoim wyjściem");

        Dist[Player[playerid][CarID]] = DOF2_GetFloat(file, "Przebieg");

        format(s, 128, "\t"L_GREEN"%s\n"WHITE"Prywatny pojazd gracza "L_GREEN"\nPrzebieg: %.1f", CarList[carid-400], PlayerName(playerid), Dist[Player[playerid][CarID]]);
        vehicle3Dtext[Player[playerid][CarID]] = Create3DTextLabel(s, COLOR_WHITE, 0.0, 0.0, 0.0, 50.0, 0, 1 );
        Attach3DTextLabelToVehicle(vehicle3Dtext[Player[playerid][CarID]], Player[playerid][CarID], 0.0, 0.0, 0.5);
        Player[playerid][Have] = true;
        IsPriv[Player[playerid][CarID]] = true;
        Player[playerid][Tim] = SetTimerEx("Pojazd", 1000, 1, "i", playerid);
       
        Loop(i, MAX_GRACZY)
        {
            if(playerid != i)
            {
                SetVehicleParamsForPlayer(Player[playerid][CarID], i, 0, 1);
                return 1;
            }
        }
    }
    return 1;
}

public OnPlayerDisconnect(playerid)
{
    if(Player[playerid][Have] == true)
    {
        if(IsPlayerInVehicle(playerid, Player[playerid][CarID])) RemovePlayerFromVehicle(playerid);

        new file[64], Float:pos[4];
        GetVehiclePos(Player[playerid][CarID], pos[0], pos[1], pos[2]);
        GetVehicleZAngle(Player[playerid][CarID], pos[3]);
       
        format(file, 64, "/Privcars/%s.ini", PlayerName(playerid));
        Delete3DTextLabel(Text3D:vehicle3Dtext[Player[playerid][CarID]]);

        DOF2_SetFloat(file, "X", pos[0]);
        DOF2_SetFloat(file, "Y", pos[1]);
        DOF2_SetFloat(file, "Z", pos[2]);
        DOF2_SetFloat(file, "A", pos[3]);
        DOF2_SetFloat(file, "Przebieg", Dist[Player[playerid][CarID]]);
        DOF2_SetInt(file, "CarID", GetVehicleModel(Player[playerid][CarID]));
        DOF2_SaveFile();
       
        IsPriv[Player[playerid][CarID]] = false;
        DestroyVehicle(Player[playerid][CarID]);
        Player[playerid][Have] = false;
        KillTimer(Player[playerid][Tim]);
    }
    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch(dialogid)
    {
        case DIALOG_PCAR:
        {
            if(response)
            {
                switch(listitem)
                {
                    case 0:
                    {
                        new Float:pos[4];
                        GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
                        GetPlayerFacingAngle(playerid, pos[3]);
                        SetVehiclePos(Player[playerid][CarID], pos[0], pos[1], pos[2]);
                        SetVehicleZAngle(Player[playerid][CarID], pos[3]);
                        if(IsPlayerInAnyVehicle(playerid)) RemovePlayerFromVehicle(playerid);
                        PutPlayerInVehicle(playerid, Player[playerid][CarID], 0);
                        return 1;
                    }
                    case 1:
                    {
                        new s[3072];
                        Loop(i, 212)
                        {
                            format(s, 3072, "%s(%d) %s\n", s, i+400, CarList[i]);
                        }
                        ShowPlayerDialog(playerid, DIALOG_CHANGEMODEL, DIALOG_STYLE_LIST, "Zmiana modelu", s, "Wybierz", "Cofnij");
                        return 1;
                    }
                }
            }
            else return 1;
        }
        case DIALOG_CHANGEMODEL:
        {
            if(response)
            {
                new Float:pos[4], s[128], file[128];
                GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
                GetPlayerFacingAngle(playerid, pos[3]);

                if(IsPlayerInAnyVehicle(playerid)) RemovePlayerFromVehicle(playerid);
                Delete3DTextLabel(Text3D:vehicle3Dtext[Player[playerid][CarID]]);
                DestroyVehicle(Player[playerid][CarID]);

                Player[playerid][CarID] = CreateVehicle(listitem+400, pos[0], pos[1], pos[2], pos[3], Player[playerid][C][0], Player[playerid][C][1], -1);
                PutPlayerInVehicle(playerid, Player[playerid][CarID], 0);
                IsPriv[Player[playerid][CarID]] = true;

                format(file, 64, "/Privcars/%s.ini", PlayerName(playerid));
                if(!DOF2_FileExists(file)) DOF2_CreateFile(file);

                DOF2_SetFloat(file, "X", pos[0]);
                DOF2_SetFloat(file, "Y", pos[1]);
                DOF2_SetFloat(file, "Z", pos[2]);
                DOF2_SetFloat(file, "A", pos[3]);
                DOF2_SetInt(file, "Color0", Player[playerid][C][0]);
                DOF2_SetInt(file, "Color1", Player[playerid][C][1]);
                DOF2_SaveFile();

                format(file, 128, " *** Gratulacje! Utworzyłeś prywatny pojazd: "BLUE"%s (ID: %d)", CarList[listitem], listitem+400);
                SCM(playerid, COLOR_WHITE, file);

                format(s, 128, "\t"L_GREEN"%s\n"WHITE"Prywatny pojazd gracza "L_GREEN"%s\nPrzebieg: %.1f", CarList[listitem], PlayerName(playerid), Dist[Player[playerid][CarID]]);
                vehicle3Dtext[Player[playerid][CarID]] = Create3DTextLabel(s, COLOR_WHITE, 0.0, 0.0, 0.0, 50.0, 0, 1);

                Attach3DTextLabelToVehicle(vehicle3Dtext[Player[playerid][CarID]], Player[playerid][CarID], 0.0, 0.0, 0.5);

                Loop(i, MAX_GRACZY)
                {
                    if(playerid != i)
                    {
                        SetVehicleParamsForPlayer(Player[playerid][CarID], i, 0, 1);
                        return 1;
                    }
                }
            }
            else return ShowPlayerDialog(playerid, DIALOG_PCAR, DIALOG_STYLE_LIST, "Prywatny pojazd", "Przywołaj pojazd\nZmień model", "Wybierz", "Wyjdź");
        }
    }
    return 1;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
    {
        new vehicleid = GetPlayerVehicleID(playerid);
        if(IsPriv[vehicleid] == true)
        {
            if(vehicleid != Player[playerid][CarID])
            {
                SCM(playerid, COLOR_WHITE, " *** To jest "ORANGE"pojazd prywatny! "WHITE"Zostałeś z niego wyrzucony");
                RemovePlayerFromVehicle(playerid);
                return 1;
            }
        }
    }
    return 1;
}

CMD:pojazd(playerid, params[])
{
    if(Player[playerid][Have] == false) return SCM(playerid, COLOR_RED, " *** Nie posiadasz prywatnego pojazdu");
    ShowPlayerDialog(playerid, DIALOG_PCAR, DIALOG_STYLE_LIST, "Prywatny pojazd", "Przywołaj pojazd\nZmień model", "Wybierz", "Wyjdź");
    return 1;
}

CMD:zmien(playerid, params[])
{
    if(!IsPlayerAdmin(playerid)) return SCM(playerid, COLOR_RED, " *** Nie jesteś adminem");
    if(sscanf(params, "ii", Type, Amount)) return SCM(playerid, -1, " *** /zmien [0 - Money, 1 - Score] [Ilość]");
    if(Type != 0 && Type != 1) return SCM(playerid, -1, " *** Zły numer sposobu [0 - Money, 1 - Score]");

    new s[64];
    format(s, 64, "Zmieniłeś typ na %d oraz ilość na %d", Type, Amount);
    SCM(playerid, COLOR_ORANGE, s);
    return 1;
}

CMD:privcar(playerid, params[])
{
    new s[128];
    switch(Type)
    {
        case 0:
        {
            if(GetPlayerMoney(playerid) < Amount)
            {
                format(s, 128, " *** Aby posiadać prywatny pojazd musisz mieć conajmniej %d kasy", Amount);
                SCM(playerid, COLOR_RED, s);
                return 1;
            }
        }
        case 1:
        {
            if(GetPlayerScore(playerid) < Amount)
            {
                format(s, 128, " *** Aby posiadać prywatny pojazd musisz mieć conajmniej %d respektu", Amount);
                SCM(playerid, COLOR_RED, s);
                return 1;
            }
        }
    }

    new id;
    if(sscanf(params, "iii", id, Player[playerid][C][0], Player[playerid][C][1])) return SCM(playerid, -1, " *** /privcar [Car ID] [Color 0] [Color 1]");
    if(id < 400 || id > 611) return SCM(playerid, -1, " *** Błędne ID pojazdu [400 - 611]");

    if(Type == 0) GivePlayerMoney(playerid, -Amount);
    else SetPlayerScore(playerid, GetPlayerScore(playerid) - Amount);

    if(Player[playerid][Have] == true)
    {
        if(IsPlayerInAnyVehicle(playerid)) RemovePlayerFromVehicle(playerid);
        Delete3DTextLabel(Text3D:vehicle3Dtext[Player[playerid][CarID]]);

        IsPriv[Player[playerid][CarID]] = false;
       
        DestroyVehicle(Player[playerid][CarID]);
    }
    else Player[playerid][Have] = true;
    new Float:pos[4], file[128];
    GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
    GetPlayerFacingAngle(playerid, pos[3]);
   
    Player[playerid][CarID] = CreateVehicle(id, pos[0], pos[1], pos[2], pos[3], Player[playerid][C][0], Player[playerid][C][1], -1);
    PutPlayerInVehicle(playerid, Player[playerid][CarID], 0);
    IsPriv[Player[playerid][CarID]] = true;
   
    KillTimer(Player[playerid][Tim]);
    Player[playerid][Tim] = SetTimerEx("Pojazd", 1000, 1, "i", playerid);

    format(file, 64, "/Privcars/%s.ini", PlayerName(playerid));
    if(!DOF2_FileExists(file)) DOF2_CreateFile(file);
   
    DOF2_SetFloat(file, "X", pos[0]);
    DOF2_SetFloat(file, "Y", pos[1]);
    DOF2_SetFloat(file, "Z", pos[2]);
    DOF2_SetFloat(file, "A", pos[3]);
    DOF2_SetInt(file, "Color0", Player[playerid][C][0]);
    DOF2_SetInt(file, "Color1", Player[playerid][C][1]);
    DOF2_SaveFile();

    format(file, 128, " *** Gratulacje! Utworzyłeś prywatny pojazd: "BLUE"%s (ID: %d)", CarList[id-400], id);
    SCM(playerid, COLOR_WHITE, file);
   
    Dist[Player[playerid][CarID]] = 0.0;
    format(s, 128, "\t"L_GREEN"%s\n"WHITE"Prywatny pojazd gracza "L_GREEN"%s\nPrzebieg: 0.0 KM", CarList[id - 400], PlayerName(playerid));
    vehicle3Dtext[Player[playerid][CarID]] = Create3DTextLabel(s, COLOR_WHITE, 0.0, 0.0, 0.0, 50.0, 0, 1);
       
    Attach3DTextLabelToVehicle(vehicle3Dtext[Player[playerid][CarID]], Player[playerid][CarID], 0.0, 0.0, 0.5);

    Loop(i, MAX_GRACZY)
    {
        if(playerid != i)
        {
            SetVehicleParamsForPlayer(Player[playerid][CarID], i, 0, 1);
            return 1;
        }
    }
    return 1;
}

forward Pojazd(i);
public Pojazd(i)
{
    new s[128], Float:ST[4], vehicleid;
    vehicleid = GetPlayerVehicleID(i);
   
    GetVehicleVelocity(vehicleid, ST[0], ST[1], ST[2]);
    ST[3] = floatsqroot(floatpower(floatabs(ST[0]), 2.0) + floatpower(floatabs(ST[1]), 2.0) + floatpower(floatabs(ST[2]), 2.0)) * 179.28625;

    Dist[vehicleid] += ST[3]/2000;

    format(s, 128, "\t"L_GREEN"%s\n"WHITE"Prywatny pojazd gracza "L_GREEN"%s\nPrzebieg: %.1f KM", CarList[GetVehicleModel(vehicleid) - 400], PlayerName(i), Dist[vehicleid]);
    Update3DTextLabelText(vehicle3Dtext[vehicleid], 0, s);
    return 1;
}

PlayerName(i)
{
    new n[24];
    GetPlayerName(i, n, 24);
    return n;
}

AntiDeAMX()
{
    new a[][] =
    {
        "Unarmed (Fist)",
        "Brass K"
    };
    #pragma unused a
}
This FS works that, when player type /privcar ID 1 2 then spawn private vehicle, for him only.
1 and 2 is colors of our vehicle.

My question is: How to change this FS to register private vehicles use /privcar MODEL 1 2 (ex. /privcar elegy 1 2)
Can someone do that?
Reply
#2

use sscnaf "s" Symbol and then https://sampwiki.blast.hk/wiki/Strcmp
Reply
#3

Could you rewrite it?
I am newbie in pawn.
Reply
#4

Resfresh. Anyone can improve it?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)