Help with a get command
#1

Ok on my car system you type, /v get. Currently you can only spawn 1 car at a time, I'm curious of how i would go about making it so you can have 2 cars out at the same time. So i type /v get 1 and my first car spawns, Then i type /v get 2 and my second car spawns, Then when i type /v get 3, You already have 2 cars out please park one before spawning another one

pawn Код:
else if(!strcmp(tmp, "get",true)) {
                new str[256];
                tmp = strtok(cmdtext, idx);
                if(!strlen(tmp)) {
                    SendClientMessage(playerid, COLOR_WHITE, "USAGE: /v get [number[1-5])");
                    return 1;
                }
                if(veh1[playerid] != 999 || veh2[playerid] != 999 || veh3[playerid] != 999 || veh4[playerid] != 999 || veh5[playerid] != 999 )
                {
                    SendClientMessage(playerid, COLOR_LIGHTRED, "    You already got a vehicle out , park it first!");
                    return 1;
                }
                if(strcmp(tmp, "1", true) == 0) {
                    if(IsVehicleSpawned(veh1[playerid])) {
                        SendClientMessage(playerid, COLOR_LIGHTRED, "You have already spawned your vehicle !");
                        new vZone[MAX_ZONE_NAME];
                        GetVehicleZone(veh1[playerid], vZone, MAX_ZONE_NAME);
                        format(string, sizeof(string), "Your %s is now in %s", VehicleNames[GetVehicleModel(veh1[playerid])-400], vZone);
                        SendClientMessage(playerid, COLOR_YELLOW, string);
                        return 1;
                    }
                    if(strcmp(PlayerInfo[playerid][pVeh1], "None", true)) {
                        format(str, sizeof(str), "Vehicles/Vehicles/%s.cfg",PlayerInfo[playerid][pVeh1]);
                        if(dini_Exists(str)) {
                            LoadVehicles(playerid, PlayerInfo[playerid][pVeh1]);

                        }
                        else SendClientMessage(playerid,COLOR_LIGHTRED, "You got bug with this vehicle please go to the admin");
                        return 1;
                    }
                    else {
                        SendClientMessage(playerid, COLOR_LIGHTRED, "You don't own any vehicle !");
                        return 1;
                    }
                }
                if(strcmp(tmp, "2", true) == 0) {
                    if(IsVehicleSpawned(veh2[playerid])) {
                        SendClientMessage(playerid, COLOR_LIGHTRED, "You have already spawned your vehicle !");
                        new vZone[MAX_ZONE_NAME];
                        GetVehicleZone(veh2[playerid], vZone, MAX_ZONE_NAME);
                        format(string, sizeof(string), "Your %s is now in %s", VehicleNames[GetVehicleModel(veh2[playerid])-400], vZone);
                        SendClientMessage(playerid, COLOR_YELLOW, string);
                        return 1;
                    }
                    if(strcmp(PlayerInfo[playerid][pVeh2], "None", true)) {
                        format(str, sizeof(str), "Vehicles/Vehicles/%s.cfg",PlayerInfo[playerid][pVeh2]);
                        if(dini_Exists(str)) {
                            LoadVehicles(playerid, PlayerInfo[playerid][pVeh2]);

                        }
                        else SendClientMessage(playerid,COLOR_LIGHTRED, "You got bug with this vehicle please go to the admin");
                        return 1;
                    }
                    else {
                        SendClientMessage(playerid, COLOR_LIGHTRED, "You don't have a 2nd vehicle!");
                        return 1;
                    }
                }
                if(strcmp(tmp, "3", true) == 0) {
                    if(IsVehicleSpawned(veh3[playerid])) {
                        SendClientMessage(playerid, COLOR_LIGHTRED, "You have already spawned your vehicle !");
                        new vZone[MAX_ZONE_NAME];
                        GetVehicleZone(veh3[playerid], vZone, MAX_ZONE_NAME);
                        format(string, sizeof(string), "Your %s is now in %s", VehicleNames[GetVehicleModel(veh3[playerid])-400], vZone);
                        SendClientMessage(playerid, COLOR_YELLOW, string);
                        return 1;
                    }
                    else {
                        if(strcmp(PlayerInfo[playerid][pVeh3], "None", true)) {
                            format(str, sizeof(str), "Vehicles/Vehicles/%s.cfg",PlayerInfo[playerid][pVeh3]);
                            if(dini_Exists(str)) {
                                LoadVehicles(playerid, PlayerInfo[playerid][pVeh3]);

                            }
                            else SendClientMessage(playerid,COLOR_LIGHTRED, "You got bug with this vehicle please go to the admin");
                            return 1;
                        }
                        else {
                            SendClientMessage(playerid, COLOR_LIGHTRED, "You don't have a 2nd vehicle!");
                            return 1;
                        }
                    }
                }
                if(strcmp(tmp, "4", true) == 0) {
                    if(IsVehicleSpawned(veh4[playerid])) {
                        SendClientMessage(playerid, COLOR_LIGHTRED, "You have already spawned your vehicle !");
                        new vZone[MAX_ZONE_NAME];
                        GetVehicleZone(veh4[playerid], vZone, MAX_ZONE_NAME);
                        format(string, sizeof(string), "Your %s is now in %s", VehicleNames[GetVehicleModel(veh4[playerid])-400], vZone);
                        SendClientMessage(playerid, COLOR_YELLOW, string);
                        return 1;
                    }
                    else {
                        if(strcmp(PlayerInfo[playerid][pVeh4], "None", true)) {
                            format(str, sizeof(str), "Vehicles/Vehicles/%s.cfg",PlayerInfo[playerid][pVeh4]);
                            if(dini_Exists(str)) {
                                LoadVehicles(playerid, PlayerInfo[playerid][pVeh4]);

                            }
                            else SendClientMessage(playerid,COLOR_LIGHTRED, "You got bug with this vehicle please go to the admin");
                            return 1;
                        }
                        else {
                            SendClientMessage(playerid, COLOR_LIGHTRED, "You don't have a 4th vehicle!");
                            return 1;
                        }
                    }
                }
                if(strcmp(tmp, "5", true) == 0) {
                    if(IsVehicleSpawned(veh5[playerid])) {
                        SendClientMessage(playerid, COLOR_LIGHTRED, "You have already spawned your vehicle !");
                        new vZone[MAX_ZONE_NAME];
                        GetVehicleZone(veh5[playerid], vZone, MAX_ZONE_NAME);
                        format(string, sizeof(string), "Your %s is now in %s", VehicleNames[GetVehicleModel(veh5[playerid])-400], vZone);
                        SendClientMessage(playerid, COLOR_YELLOW, string);
                        return 1;
                    }
                    if(strcmp(PlayerInfo[playerid][pVeh5], "None", true)) {
                        format(str, sizeof(str), "Vehicles/Vehicles/%s.cfg",PlayerInfo[playerid][pVeh5]);
                        if(dini_Exists(str)) {
                            LoadVehicles(playerid, PlayerInfo[playerid][pVeh5]);

                        }
                        else SendClientMessage(playerid,COLOR_LIGHTRED, "You got bug with this vehicle please go to the admin");
                        return 1;
                    }
                    else {
                        SendClientMessage(playerid, COLOR_LIGHTRED, "You don't have a 5th vehicle!!");
                        return 1;
                    }
                }
                return 1;
            }
Reply
#2

Nothing ?
Reply
#3

Some mind helping me with this? It will be appericated.
Reply
#4

Yes i am bumping this again, There must be someway to do what i need
Reply
#5

Okay if I understood you correctly, you simply want to allow 2 cars instead of 1 right? Then you could do something like so.

pawn Код:
else if(!strcmp(tmp, "get",true))
{
    new str[256];
    new vehcount;
    tmp = strtok(cmdtext, idx);
    if(!strlen(tmp)) {
        SendClientMessage(playerid, COLOR_WHITE, "USAGE: /v get [number[1-5])");
        return 1;
    }
    if(veh1[playerid] != 999) vehcount++;
    if(veh2[playerid] != 999) vehcount++;
    if(veh3[playerid] != 999) vehcount++;
    if(veh4[playerid] != 999) vehcount++;
    if(veh5[playerid] != 999) vehcount++;
    if(vehcount >= 2) return SendClientMessage(playerid,COLOR_LIGHTRED,"You already have 2 cars out please park one before spawning another one"); // Player has 2 or more cars spawned, stop him from spawning more
    if(strcmp(tmp, "1", true) == 0) {
        if(IsVehicleSpawned(veh1[playerid])) {
            SendClientMessage(playerid, COLOR_LIGHTRED, "You have already spawned your vehicle !");
            new vZone[MAX_ZONE_NAME];
            GetVehicleZone(veh1[playerid], vZone, MAX_ZONE_NAME);
            format(string, sizeof(string), "Your %s is now in %s", VehicleNames[GetVehicleModel(veh1[playerid])-400], vZone);
            SendClientMessage(playerid, COLOR_YELLOW, string);
            return 1;
        }
        if(strcmp(PlayerInfo[playerid][pVeh1], "None", true)) {
            format(str, sizeof(str), "Vehicles/Vehicles/%s.cfg",PlayerInfo[playerid][pVeh1]);
            if(dini_Exists(str)) {
                LoadVehicles(playerid, PlayerInfo[playerid][pVeh1]);

            }
            else SendClientMessage(playerid,COLOR_LIGHTRED, "You got bug with this vehicle please go to the admin");
            return 1;
        }
        else {
            SendClientMessage(playerid, COLOR_LIGHTRED, "You don't own any vehicle !");
            return 1;
        }
    }
    if(strcmp(tmp, "2", true) == 0) {
        if(IsVehicleSpawned(veh2[playerid])) {
            SendClientMessage(playerid, COLOR_LIGHTRED, "You have already spawned your vehicle !");
            new vZone[MAX_ZONE_NAME];
            GetVehicleZone(veh2[playerid], vZone, MAX_ZONE_NAME);
            format(string, sizeof(string), "Your %s is now in %s", VehicleNames[GetVehicleModel(veh2[playerid])-400], vZone);
            SendClientMessage(playerid, COLOR_YELLOW, string);
            return 1;
        }
        if(strcmp(PlayerInfo[playerid][pVeh2], "None", true)) {
            format(str, sizeof(str), "Vehicles/Vehicles/%s.cfg",PlayerInfo[playerid][pVeh2]);
            if(dini_Exists(str)) {
                LoadVehicles(playerid, PlayerInfo[playerid][pVeh2]);

            }
            else SendClientMessage(playerid,COLOR_LIGHTRED, "You got bug with this vehicle please go to the admin");
            return 1;
        }
        else {
            SendClientMessage(playerid, COLOR_LIGHTRED, "You don't have a 2nd vehicle!");
            return 1;
        }
    }
    if(strcmp(tmp, "3", true) == 0) {
        if(IsVehicleSpawned(veh3[playerid])) {
            SendClientMessage(playerid, COLOR_LIGHTRED, "You have already spawned your vehicle !");
            new vZone[MAX_ZONE_NAME];
            GetVehicleZone(veh3[playerid], vZone, MAX_ZONE_NAME);
            format(string, sizeof(string), "Your %s is now in %s", VehicleNames[GetVehicleModel(veh3[playerid])-400], vZone);
            SendClientMessage(playerid, COLOR_YELLOW, string);
            return 1;
        }
        else {
            if(strcmp(PlayerInfo[playerid][pVeh3], "None", true)) {
                format(str, sizeof(str), "Vehicles/Vehicles/%s.cfg",PlayerInfo[playerid][pVeh3]);
                if(dini_Exists(str)) {
                    LoadVehicles(playerid, PlayerInfo[playerid][pVeh3]);

                }
                else SendClientMessage(playerid,COLOR_LIGHTRED, "You got bug with this vehicle please go to the admin");
                return 1;
            }
            else {
                SendClientMessage(playerid, COLOR_LIGHTRED, "You don't have a 2nd vehicle!");
                return 1;
            }
        }
    }
    if(strcmp(tmp, "4", true) == 0) {
        if(IsVehicleSpawned(veh4[playerid])) {
            SendClientMessage(playerid, COLOR_LIGHTRED, "You have already spawned your vehicle !");
            new vZone[MAX_ZONE_NAME];
            GetVehicleZone(veh4[playerid], vZone, MAX_ZONE_NAME);
            format(string, sizeof(string), "Your %s is now in %s", VehicleNames[GetVehicleModel(veh4[playerid])-400], vZone);
            SendClientMessage(playerid, COLOR_YELLOW, string);
            return 1;
        }
        else {
            if(strcmp(PlayerInfo[playerid][pVeh4], "None", true)) {
                format(str, sizeof(str), "Vehicles/Vehicles/%s.cfg",PlayerInfo[playerid][pVeh4]);
                if(dini_Exists(str)) {
                    LoadVehicles(playerid, PlayerInfo[playerid][pVeh4]);

                }
                else SendClientMessage(playerid,COLOR_LIGHTRED, "You got bug with this vehicle please go to the admin");
                return 1;
            }
            else {
                SendClientMessage(playerid, COLOR_LIGHTRED, "You don't have a 4th vehicle!");
                return 1;
            }
        }
    }
    if(strcmp(tmp, "5", true) == 0) {
        if(IsVehicleSpawned(veh5[playerid])) {
            SendClientMessage(playerid, COLOR_LIGHTRED, "You have already spawned your vehicle !");
            new vZone[MAX_ZONE_NAME];
            GetVehicleZone(veh5[playerid], vZone, MAX_ZONE_NAME);
            format(string, sizeof(string), "Your %s is now in %s", VehicleNames[GetVehicleModel(veh5[playerid])-400], vZone);
            SendClientMessage(playerid, COLOR_YELLOW, string);
            return 1;
        }
        if(strcmp(PlayerInfo[playerid][pVeh5], "None", true)) {
            format(str, sizeof(str), "Vehicles/Vehicles/%s.cfg",PlayerInfo[playerid][pVeh5]);
            if(dini_Exists(str)) {
                LoadVehicles(playerid, PlayerInfo[playerid][pVeh5]);

            }
            else SendClientMessage(playerid,COLOR_LIGHTRED, "You got bug with this vehicle please go to the admin");
            return 1;
        }
        else {
            SendClientMessage(playerid, COLOR_LIGHTRED, "You don't have a 5th vehicle!!");
            return 1;
        }
    }
    return 1;
}
Reply
#6

yes, you didn't have to rescirpt it for me, I just need to know how but thank you for the help. It's hard to get help on the forums nown days
Reply
#7

Quote:
Originally Posted by ihatetn931
Посмотреть сообщение
yes, you didn't have to rescirpt it for me, I just need to know how but thank you for the help. It's hard to get help on the forums nown days
It's only an example, I'm sure there are better ways of doing it!
Reply
#8

Quote:
Originally Posted by JaTochNietDan
Посмотреть сообщение
It's only an example, I'm sure there are better ways of doing it!
I'm sure there is to, But since i suck at pawno and still in the process of learning. I couldn't do it myself. Thank you once again for the help
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)