findcar
#1

hi i wish to make Poeple have a ability to find 5 cars they own
lines

PHP код:
   if(strcmp(cmd"/findcar"true) == 0// By DraGoN
    
{
        if(
IsPlayerConnected(playerid))
        {
            
tmp strtok(cmdtextidx);
            if(!
strlen(tmp))
            {
                
SendClientMessage(playeridCOLOR_WHITE"Example: /findcar [1, 2]");
                return 
1;
            }
            new 
number strval(tmp);
            if(
number || number 2)
                {
                    
SendClientMessage(playeridCOLOR_GREY"Vehicle  1, 2");
                    return 
1;
                }
            if(
number == 1)
            {
                if(
PlayerInfo[playerid][pPcarkey] == 9999)
                {
                    
SendClientMessage(playeridCOLOR_GREY"No Vehicle found in this slot 1!");
                    return 
1;
                }
                new 
carid PlayerInfo[playerid][pPcarkey];
                new 
Float:XFloat:YFloat:Z;
                new 
zone[MAX_ZONE_NAME];
                
GetVehicle2DZone(caridzoneMAX_ZONE_NAME);
                
GetVehiclePos(caridX,Y,Z);
                if(
Searching[playerid] == 0)
                {
                    
Searching[playerid] = 1;
                    
SetPlayerCheckpoint(playeridX,Y,Z5.0);
                    
format(stringsizeof(string),"Checpoint has been placed!",zone);
                    
SendClientMessage(playeridTEAM_GROVE_COLORstring);
                }
                else
                {
                    
SetPlayerCheckpoint(playeridX,Y,Z5.0);
                    
format(stringsizeof(string),"Checkpoint has been placed!",zone);
                    
SendClientMessage(playeridTEAM_GROVE_COLORstring);
                }
            }
                   else if(
number == 2)
            {
                if(
PlayerInfo[playerid][pPcarkey2] == 9999)
                {
                    
SendClientMessage(playeridCOLOR_GREY"No Vehicle found in this slot 2");
                    return 
1;
                }
                new 
carid PlayerInfo[playerid][pPcarkey2];
                new 
Float:XFloat:YFloat:Z;
                new 
zone[MAX_ZONE_NAME];
                
GetVehicle2DZone(caridzoneMAX_ZONE_NAME);
                
GetVehiclePos(caridX,Y,Z);
                if(
Searching[playerid] == 0)
                {
                    
Searching[playerid] = 1;
                    
SetPlayerCheckpoint(playeridX,Y,Z5.0);
                    
format(stringsizeof(string),"Checkpoint has been placed!",zone);
                    
SendClientMessage(playeridTEAM_GROVE_COLORstring);
                }
                else
                {
                    
SetPlayerCheckpoint(playeridX,Y,Z5.0);
                    
format(stringsizeof(string),"Checkpoint has been placed!",zone);
                    
SendClientMessage(playeridTEAM_GROVE_COLORstring);
                }
            }
        }
    } 
Ok i wish this to have 5 cars u can find i did it like this

lines:


PHP код:
    if(strcmp(cmd"/findcar"true) == 0// By Don rodriquez
    
{
        if(
IsPlayerConnected(playerid))
        {
            
tmp strtok(cmdtextidx);
            if(!
strlen(tmp))
            {
                
SendClientMessage(playeridCOLOR_WHITE"Example: /findcar [1, 2, 3, 4, 5]");
                return 
1;
            }
            new 
number strval(tmp);
            if(
number || number || number || number || number 5)
                {
                    
SendClientMessage(playeridCOLOR_GREY"Vehicle  1, 2, 3, 4, 5");
                    return 
1;
                }
            if(
number == 1)
            {
                if(
PlayerInfo[playerid][pPcarkey] == 9999)
                {
                    
SendClientMessage(playeridCOLOR_GREY"No Vehicle found in this slot 1!");
                    return 
1;
                }
                new 
carid PlayerInfo[playerid][pPcarkey];
                new 
Float:XFloat:YFloat:Z;
                new 
zone[MAX_ZONE_NAME];
                
GetVehicle2DZone(caridzoneMAX_ZONE_NAME);
                
GetVehiclePos(caridX,Y,Z);
                if(
Searching[playerid] == 0)
                {
                    
Searching[playerid] = 1;
                    
SetPlayerCheckpoint(playeridX,Y,Z5.0);
                    
format(stringsizeof(string),"Checpoint has been placed!",zone);
                    
SendClientMessage(playeridTEAM_GROVE_COLORstring);
                }
                else
                {
                    
SetPlayerCheckpoint(playeridX,Y,Z5.0);
                    
format(stringsizeof(string),"Checkpoint has been placed!",zone);
                    
SendClientMessage(playeridTEAM_GROVE_COLORstring);
                }
            }
                   else if(
number == 2)
            {
                if(
PlayerInfo[playerid][pPcarkey2] == 9999)
                {
                    
SendClientMessage(playeridCOLOR_GREY"No Vehicle found in this slot 2");
                    return 
1;
                }
                new 
carid PlayerInfo[playerid][pPcarkey2];
                new 
Float:XFloat:YFloat:Z;
                new 
zone[MAX_ZONE_NAME];
                
GetVehicle2DZone(caridzoneMAX_ZONE_NAME);
                
GetVehiclePos(caridX,Y,Z);
                if(
Searching[playerid] == 0)
                {
                    
Searching[playerid] = 1;
                    
SetPlayerCheckpoint(playeridX,Y,Z5.0);
                    
format(stringsizeof(string),"Checkpoint has been placed!",zone);
                    
SendClientMessage(playeridTEAM_GROVE_COLORstring);
                }
                else
                {
                    
SetPlayerCheckpoint(playeridX,Y,Z5.0);
                    
format(stringsizeof(string),"Checkpoint has been placed!",zone);
                    
SendClientMessage(playeridTEAM_GROVE_COLORstring);
                }
            }
                   else if(
number == 3)
            {
                if(
PlayerInfo[playerid][pPcarkey3] == 9999)
                {
                    
SendClientMessage(playeridCOLOR_GREY"No Vehicle found in this slot 3");
                    return 
1;
                }
                new 
carid PlayerInfo[playerid][pPcarkey3];
                new 
Float:XFloat:YFloat:Z;
                new 
zone[MAX_ZONE_NAME];
                
GetVehicle2DZone(caridzoneMAX_ZONE_NAME);
                
GetVehiclePos(caridX,Y,Z);
                if(
Searching[playerid] == 0)
                {
                    
Searching[playerid] = 1;
                    
SetPlayerCheckpoint(playeridX,Y,Z5.0);
                    
format(stringsizeof(string),"Checkpoint has been placed!",zone);
                    
SendClientMessage(playeridTEAM_GROVE_COLORstring);
                }
                else
                {
                    
SetPlayerCheckpoint(playeridX,Y,Z5.0);
                    
format(stringsizeof(string),"Checkpoint has been placed!",zone);
                    
SendClientMessage(playeridTEAM_GROVE_COLORstring);
                }
            }
                   else if(
number == 4)
            {
                if(
PlayerInfo[playerid][pPcarkey4] == 9999)
                {
                    
SendClientMessage(playeridCOLOR_GREY"No Vehicle found in this slot 4");
                    return 
1;
                }
                new 
carid PlayerInfo[playerid][pPcarkey4];
                new 
Float:XFloat:YFloat:Z;
                new 
zone[MAX_ZONE_NAME];
                
GetVehicle2DZone(caridzoneMAX_ZONE_NAME);
                
GetVehiclePos(caridX,Y,Z);
                if(
Searching[playerid] == 0)
                {
                    
Searching[playerid] = 1;
                    
SetPlayerCheckpoint(playeridX,Y,Z5.0);
                    
format(stringsizeof(string),"Checkpoint has been placed!",zone);
                    
SendClientMessage(playeridTEAM_GROVE_COLORstring);
                }
                else
                {
                    
SetPlayerCheckpoint(playeridX,Y,Z5.0);
                    
format(stringsizeof(string),"Checkpoint has been placed!",zone);
                    
SendClientMessage(playeridTEAM_GROVE_COLORstring);
                }
            }
                   else if(
number == 5)
            {
                if(
PlayerInfo[playerid][pPcarkey5] == 9999)
                {
                    
SendClientMessage(playeridCOLOR_GREY"No Vehicle found in this slot 5");
                    return 
1;
                }
                new 
carid PlayerInfo[playerid][pPcarkey5];
                new 
Float:XFloat:YFloat:Z;
                new 
zone[MAX_ZONE_NAME];
                
GetVehicle2DZone(caridzoneMAX_ZONE_NAME);
                
GetVehiclePos(caridX,Y,Z);
                if(
Searching[playerid] == 0)
                {
                    
Searching[playerid] = 1;
                    
SetPlayerCheckpoint(playeridX,Y,Z5.0);
                    
format(stringsizeof(string),"Checkpoint has been placed!",zone);
                    
SendClientMessage(playeridTEAM_GROVE_COLORstring);
                }
                else
                {
                    
SetPlayerCheckpoint(playeridX,Y,Z5.0);
                    
format(stringsizeof(string),"Checkpoint has been placed!",zone);
                    
SendClientMessage(playeridTEAM_GROVE_COLORstring);
                }
            }
        }
    } 
but this 1 doesnt work
Reply
#2

Sorry for bad english i ment to say I have made poeple have an ability to own 5 cars , but now findcar doesnt work for the 3 other cars , But it does work for the other 2 cars anyone may edit firsht lines i gave for 5 cars?
Reply
#3

any 1 ?
Reply
#4

Its all about those lines ,
PHP код:
 if(number || number 2
When i put it like this
PHP код:
if (number || number || number || number || number 5
It will only work For ID 1 -2
but when i put it like this
PHP код:
if(number || number || number || number || number 5
it will find 4-5 and others it wont
Please help XD
Reply
#5

pawn Код:
number<1 || number > 2 || number > 3 || number > 4 || number > 5
number < 1 || number < 2 || number < 3 || number < 4 || number < 5
These lines makes no sense.
First line checks if number is less than 1 or if it is greater than 2
Second line checks if number is less than 5

Try using this instead
pawn Код:
if(number<1 || number >5) return SendClientMessage(playerid, COLOR_GREY, "Vehicle  1, 2, 3, 4, 5");
//Your other code.
Reply
#6

try that..
it says.

number must be bigger than 0 and less or equal to 5.
pawn Код:
if (number > 0 || number <= 5)
Reply
#7

Both of yours Doesnt work . Anyone?
Reply
#8

As for the limit of the cars owned:

pawn Код:
if(Number < 1 || number < 5) return SendClientMessage(playerid, COLOR_GREY, "ERROR: Vehicles are from 1 to 5 only.");
As for the other three vehicles, make sure about the comand that makes you buy a vehicle sets a value for the PlayerInfo[playerid][pPcarkey3], PlayerInfo[playerid][pPcarkey4] and PlayerInfo[playerid][pPcarkey5].
Reply
#9

1. If someone typed a command and OnPlayerCommandText gets called he is connected!
2. strtok is out-dated, use sscanf or something else
3. use arrays or function to stop bloating your code
4. strcmp is only efficient if you got under ~ 10 commands

I just gonna fix your code
pawn Код:
//
    if(strcmp(cmd, "/findcar", true) == 0) {
        if(!strlen((tmp = strtok(cmdtext, idx)))) {
            SendClientMessage(playerid, COLOR_WHITE, "Example: /findcar [1, 2, 3, 4, 5]");
            return 1;
        }
        new
            number = strval(tmp)
        ;
        if(!(1 <= number <= 5)) {
            SendClientMessage(playerid, COLOR_GREY, "Vehicle  1, 2, 3, 4, 5");
            return 1;
        }
        new
            vehicleid
        ;
        switch(number) { // use arrays...
            case 1: vehicleid = PlayerInfo[playerid][pPcarkey];
            case 2: vehicleid = PlayerInfo[playerid][pPcarkey2];
            case 3: vehicleid = PlayerInfo[playerid][pPcarkey3];
            case 4: vehicleid = PlayerInfo[playerid][pPcarkey4];
            case 5: vehicleid = PlayerInfo[playerid][pPcarkey5];
        }
        if(vehicleid == 9999) {
            string = "No Vehicle found in this slot X!";
            string[30] = '0' + number;
            SendClientMessage(playerid, COLOR_GREY, string);
            return 1;
        }
        new
            Float: X,
            Float: Y,
            Float: Z
        ;
        GetVehiclePos(vehicleid, X, Y, Z);
        SetPlayerCheckpoint(playerid, X, Y, Z, 5.0);
        SendClientMessage(playerid, TEAM_GROVE_COLOR, "Checkpoint has been placed!");
        return (Searching[playerid] = 1);
    }
Reply
#10

Bro I already made it Work but Still thanks Ill keep this 1

Edit I forgot to give you rep LOL! here ya go
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)