Rent Car System Stopped Working.
#1

Fixed


Ok so It was working when I didn't have the createpickup or create3dtextlabel in then it stopped, I tried it with the streamer as well but the pickups or textlabels don't show. Also when you press H has now stopped working.

Full code of my rent system.
pawn Код:
// PRESSED(keys)
#define PRESSED(%0) \
    (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))

new VehicleNames[212][] = {
   "Landstalker",  "Bravura",  "Buffalo", "Linerunner", "Perennial", "Sentinel",
   "Dumper",  "Firetruck" ,  "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",  "Previon", "Coach", "Cabbie",
   "Stallion", "Rumpo", "RC Bandit",  "Romero", "Packer", "Monster",  "Admiral",
   "Squalo", "Seasparrow", "Pizzaboy", "Tram", "Trailer",  "Turismo", "Speeder",
   "Reefer", "Tropic", "Flatbed","Yankee", "Caddy", "Solair","Berkley's RC Van",
   "Skimmer", "PCJ-600", "Faggio", "Freeway", "RC Baron","RC Raider","Glendale",
   "Oceanic", "Sanchez", "Sparrow",  "Patriot", "Quad",  "Coastguard", "Dinghy",
   "Hermes", "Sabre", "Rustler", "ZR-350", "Walton",  "Regina",  "Comet", "BMX",
   "Burrito", "Camper", "Marquis", "Baggage", "Dozer","Maverick","News Chopper",
   "Rancher", "FBI Rancher", "Virgo", "Greenwood","Jetmax","Hotring","Sandking",
   "Blista Compact", "Police Maverick", "Boxville", "Benson","Mesa","RC Goblin",
   "Hotring Racer", "Hotring Racer", "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", "Hustler", "Intruder", "Primo", "Cargobob",  "Tampa",
   "Sunrise", "Merit",  "Utility Truck",  "Nevada", "Yosemite", "Windsor",  "Monster",
   "Monster","Uranus","Jester","Sultan","Stratum","Elegy","Raindance","RCTiger",
   "Flash","Tahoma","Savanna", "Bandito", "Freight", "Trailer", "Kart", "Mower",
   "Dune", "Sweeper", "Broadway", "Tornado", "AT-400",  "DFT-30", "Huntley",
   "Stafford", "BF-400", "Newsvan","Tug","Trailer","Emperor","Wayfarer","Euros",
   "Hotdog", "Club", "Trailer", "Trailer","Andromada","Dodo","RC Cam", "Launch",
   "Police Car (LSPD)", "Police Car (SFPD)","Police Car (LVPD)","Police Ranger",
   "Picador",   "S.W.A.T. Van",  "Alpha",   "Phoenix",   "Glendale",   "Sadler",
   "Luggage Trailer","Luggage Trailer","Stair Trailer", "Boxville", "Farm Plow",
   "Utility Trailer"
};

enum vInfo
{
    vEngine,
    vWindows,
    vType, // 0: None, 1: Rental, 2: Ownable, 3: Admin Vehicle, 4: Trucker, 5: Garbage Man, 6: Sweet Sweeper, 7:
};
new VehicleInfo[MAX_VEHICLES][vInfo];

#define MAX_RENTPOS 12
enum rInfo
{
    Float:RX,
    Float:RY,
    Float:RZ,
    Float:RSX,
    Float:RSY,
    Float:RSZ,
    Float:RSA,
    VehID,
    VehRentPrice
};
new RentInfo[MAX_RENTPOS][rInfo];

enum RentCarInfo
{
    Created,
    RentID,
    Owner[MAX_PLAYER_NAME]
};
new rcarInfo[MAX_VEHICLES][RentCarInfo];

new Text3D:RentCar3D[MAX_RENTPOS];
new RentPickUp[MAX_RENTPOS];

//commands
COMMAND:create(playerid, params[])
{
    if(GetPVarInt(playerid, "Admin") >= 9 || IsPlayerAdmin(playerid))
    {
        ShowPlayerDialog(playerid, 13, DIALOG_STYLE_LIST, "Creation Menu", "Rent Car Location\nBank\nATM", "Continue", "Cancel");
        return 1;
    }
    else return SendClientMessage(playerid, COLOR_RED, "Error: You can't use this command.");
}

//key state change
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(newkeys & KEY_CTRL_BACK)
    {
        new i = GetRentCarID(playerid);
        if(IsPlayerInRangeOfPoint(playerid,5.0,RentInfo[i][RZ], RentInfo[i][RZ], RentInfo[i][RZ]))
        {
            new string[256];
            format(string, sizeof(string), "You can rent a %s for $%d\n per payday.", GetVehicleName(RentInfo[i][VehID]), RentInfo[i][VehRentPrice]);
            ShowPlayerDialog(playerid,16, DIALOG_STYLE_INPUT, "Vehicle Rental", string, "Yes", "No");
        }
    }
    return 1;
}
//dialog

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
switch(dialogid) //rent car
    {
        case 13:
        {
            if(!response)
            {
                SendClientMessage(playerid, 0x42F3F198, "Teleports canceled.");
                return 1;
            }
            switch(listitem)
            {
                case 0:
                {
                    new i = GetRentCars();
                    new Float:x,Float:y,Float:z;
                    if(i < 12)
                    {
                        GetPlayerPos(playerid,x,y,z);
                        PRCX[playerid] = x;
                        PRCY[playerid] = z;
                        PRCZ[playerid] = y;
                        ShowPlayerDialog(playerid,14, DIALOG_STYLE_INPUT, "Rent Veh ID", "Enter the Vehicle ID of the Rent Car:", "Done", "Cancel");
                    }
                }
                case 1:
                {
                    SendClientMessage(playerid, COLOR_RED, "Not made yet.");
                }
                case 2:
                {
                    SendClientMessage(playerid, COLOR_RED, "Not made yet.");
                }
            }
        }
    }
    switch(dialogid) //rent car
    {
        case 14:
        {
            if(!response) return SendClientMessage(playerid, 0x42F3F198, "Rent Car Creation Ended.");
            if(!strlen(inputtext)) return ShowPlayerDialog(playerid,14, DIALOG_STYLE_INPUT, "Rent Veh ID", "Enter the Vehicle ID of the Rent Car:", "Done", "Cancel");
            if(strlen(inputtext) >= 7) return ShowPlayerDialog(playerid,14, DIALOG_STYLE_INPUT, "Rent Veh ID", "Enter the Vehicle ID of the Rent Car:", "Done", "Cancel");
            new amount = strval(inputtext);
            PRCVehID[playerid] = amount;
            ShowPlayerDialog(playerid,15, DIALOG_STYLE_INPUT, "Rent Veh Price", "Enter the Vehicle Price of the Rent Car\n (This is per hour):", "Done", "Cancel");
        }
    }
    switch(dialogid) //rent car
    {
        case 15:
        {
            if(!response) return SendClientMessage(playerid, 0x42F3F198, "Rent Car Creation Ended.");
            if(!strlen(inputtext)) return ShowPlayerDialog(playerid,15, DIALOG_STYLE_INPUT, "Rent Veh Price", "Enter the Vehicle Price of the Rent Car\n (This is per hour):", "Done", "Cancel");
            if(strlen(inputtext) >= 7) return ShowPlayerDialog(playerid,15, DIALOG_STYLE_INPUT, "Rent Veh Price", "Enter the Vehicle Price of the Rent Car\n (This is per hour):", "Done", "Cancel");
            new amount = strval(inputtext);
            new i = GetRentCars();
            new rc[256];
            format(rc, sizeof(rc), "RentCars/%d.ini",i);
            PCRVehPrice[playerid] = amount;
            DOF2_CreateFile(rc);
            DOF2_SetFloat(rc, "X", PRCX[playerid]);
            DOF2_SetFloat(rc, "Y", PRCY[playerid]);
            DOF2_SetFloat(rc, "Z", PRCZ[playerid]);
            DOF2_SetInt(rc, "ID", PRCVehID[playerid]);
            DOF2_SetInt(rc, "VehPrice", PCRVehPrice[playerid]);
            DOF2_WriteFile();
            RentInfo[i][VehRentPrice] = PCRVehPrice[playerid];
            RentInfo[i][VehID] = PRCVehID[playerid];
            RentInfo[i][RZ] = PRCZ[playerid];
            RentInfo[i][RY] = PRCY[playerid];
            RentInfo[i][RX] = PRCX[playerid];
            new Float:x,Float:y,Float:z;
            GetPlayerPos(playerid,x,y,z);
            RentCar3D[i] =  Create3DTextLabel("Press H to open rent vehicle\n Selection", 0x008080FF, x, y, z, 40.0, -1, 0);
            RentPickUp[i] = CreatePickup(1239, 1, x, y, z, -1);
            SendClientMessage(playerid, 0x42F3F198, "Rent Car Creation Ended.");
        }
    }
    switch(dialogid) //rent car
    {
        case 16:
        {
            if(!response) return SendClientMessage(playerid, 0x42F3F198, "Rent Car selection canceled.");
            new sendername[MAX_PLAYER_NAME];
            GetPlayerName(playerid, sendername, sizeof(sendername));
            for(new car = 0; car < MAX_VEHICLES; car++)
            {
                if(rcarInfo[car][Created] == 1)
                {
                    if(strcmp(rcarInfo[car][Owner], sendername, true) == 0)
                    {
                        SendClientMessage(playerid, COLOR_RED, " You already have a vehicle spawned, please /unrent");
                        return 1;
                    }
                }
            }
            new i = GetRentCars();
            new veh;
            veh = CreateVehicle(RentInfo[i][VehID], RentInfo[i][RSX], RentInfo[i][RSY], RentInfo[i][RSZ], RentInfo[i][RSA], 0, 0, 0);
            rcarInfo[veh][Created] = 1;
            VehicleInfo[veh][vType] = 1;
            strmid(rcarInfo[veh][Owner], sendername, 0, strlen(sendername), 255);
            SendClientMessage(playerid,COLOR_LIGHTBLUE,"Vehicle Rented, Rember to /unrent.");
        }
    }
}

//stocks
stock LoadRentCars()
{
    for(new i = 0; i < MAX_RENTPOS;i++)
    {
        new rc[256];
        format(rc, sizeof(rc), "RentCars/%d.ini",i);
        if(DOF2_FileExists(rc))
        {
            RentInfo[i][RX] = DOF2_GetFloat(rc, "X");
            RentInfo[i][RY] = DOF2_GetFloat(rc, "Y");
            RentInfo[i][RZ] = DOF2_GetFloat(rc, "Z");
            RentInfo[i][VehID] = DOF2_GetInt(rc, "ID");
            RentInfo[i][VehRentPrice] = DOF2_GetInt(rc, "VehPrice");
            RentCar3D[i] =  Create3DTextLabel("Press H to open rent vehicle\n Selection", 0x008080FF, RentInfo[i][RX], RentInfo[i][RY], RentInfo[i][RZ], 40.0, 0, 1);
            RentPickUp[i] = CreatePickup(1239, 1, RentInfo[i][RX], RentInfo[i][RY], RentInfo[i][RZ], -1);
        }
    }
    printf("Rent Cars created");
}

stock GetRentCars()
{
    new file[60];
    for(new i = 0; i < MAX_RENTPOS;i++)
    {
        format(file,sizeof(file),"RentCars/%i.ini",i);
        if(!DOF2_FileExists(file)) return i;
    }
    return -1;
}

stock GetRentCarID(playerid)
{
    for(new i=0; i < MAX_RENTPOS; i++)
    {
        if(PlayerToPoint(5.0, playerid, RentInfo[i][RX],RentInfo[i][RY],RentInfo[i][RZ]))
        {
            return i;
        }
    }
    return 1;
}

stock GetVehicleName(vehicleid)
{
    new String[256];
    format(String,sizeof(String),"%s",VehicleNames[GetVehicleModel(vehicleid) - 400]);
    return String;
}
It was working intill I put createpickup and create3dtextlabel I even removed them and it stopped working. Before I put the pickups and text labels in I would /create then a rent car dealership and press h and it would open the dialog I would then move away and press H it wouldn't I would create the new rent car dealership and It would open the new dialog with the new rent car.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)