findcar -
kepa333 - 20.06.2012
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(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_WHITE, "Example: /findcar [1, 2]");
return 1;
}
new number = strval(tmp);
if(number < 1 || number > 2)
{
SendClientMessage(playerid, COLOR_GREY, "Vehicle 1, 2");
return 1;
}
if(number == 1)
{
if(PlayerInfo[playerid][pPcarkey] == 9999)
{
SendClientMessage(playerid, COLOR_GREY, "No Vehicle found in this slot 1!");
return 1;
}
new carid = PlayerInfo[playerid][pPcarkey];
new Float:X, Float:Y, Float:Z;
new zone[MAX_ZONE_NAME];
GetVehicle2DZone(carid, zone, MAX_ZONE_NAME);
GetVehiclePos(carid, X,Y,Z);
if(Searching[playerid] == 0)
{
Searching[playerid] = 1;
SetPlayerCheckpoint(playerid, X,Y,Z, 5.0);
format(string, sizeof(string),"Checpoint has been placed!",zone);
SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
}
else
{
SetPlayerCheckpoint(playerid, X,Y,Z, 5.0);
format(string, sizeof(string),"Checkpoint has been placed!",zone);
SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
}
}
else if(number == 2)
{
if(PlayerInfo[playerid][pPcarkey2] == 9999)
{
SendClientMessage(playerid, COLOR_GREY, "No Vehicle found in this slot 2");
return 1;
}
new carid = PlayerInfo[playerid][pPcarkey2];
new Float:X, Float:Y, Float:Z;
new zone[MAX_ZONE_NAME];
GetVehicle2DZone(carid, zone, MAX_ZONE_NAME);
GetVehiclePos(carid, X,Y,Z);
if(Searching[playerid] == 0)
{
Searching[playerid] = 1;
SetPlayerCheckpoint(playerid, X,Y,Z, 5.0);
format(string, sizeof(string),"Checkpoint has been placed!",zone);
SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
}
else
{
SetPlayerCheckpoint(playerid, X,Y,Z, 5.0);
format(string, sizeof(string),"Checkpoint has been placed!",zone);
SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
}
}
}
}
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(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_WHITE, "Example: /findcar [1, 2, 3, 4, 5]");
return 1;
}
new number = strval(tmp);
if(number < 1 || number > 2 || number > 3 || number > 4 || number > 5)
{
SendClientMessage(playerid, COLOR_GREY, "Vehicle 1, 2, 3, 4, 5");
return 1;
}
if(number == 1)
{
if(PlayerInfo[playerid][pPcarkey] == 9999)
{
SendClientMessage(playerid, COLOR_GREY, "No Vehicle found in this slot 1!");
return 1;
}
new carid = PlayerInfo[playerid][pPcarkey];
new Float:X, Float:Y, Float:Z;
new zone[MAX_ZONE_NAME];
GetVehicle2DZone(carid, zone, MAX_ZONE_NAME);
GetVehiclePos(carid, X,Y,Z);
if(Searching[playerid] == 0)
{
Searching[playerid] = 1;
SetPlayerCheckpoint(playerid, X,Y,Z, 5.0);
format(string, sizeof(string),"Checpoint has been placed!",zone);
SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
}
else
{
SetPlayerCheckpoint(playerid, X,Y,Z, 5.0);
format(string, sizeof(string),"Checkpoint has been placed!",zone);
SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
}
}
else if(number == 2)
{
if(PlayerInfo[playerid][pPcarkey2] == 9999)
{
SendClientMessage(playerid, COLOR_GREY, "No Vehicle found in this slot 2");
return 1;
}
new carid = PlayerInfo[playerid][pPcarkey2];
new Float:X, Float:Y, Float:Z;
new zone[MAX_ZONE_NAME];
GetVehicle2DZone(carid, zone, MAX_ZONE_NAME);
GetVehiclePos(carid, X,Y,Z);
if(Searching[playerid] == 0)
{
Searching[playerid] = 1;
SetPlayerCheckpoint(playerid, X,Y,Z, 5.0);
format(string, sizeof(string),"Checkpoint has been placed!",zone);
SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
}
else
{
SetPlayerCheckpoint(playerid, X,Y,Z, 5.0);
format(string, sizeof(string),"Checkpoint has been placed!",zone);
SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
}
}
else if(number == 3)
{
if(PlayerInfo[playerid][pPcarkey3] == 9999)
{
SendClientMessage(playerid, COLOR_GREY, "No Vehicle found in this slot 3");
return 1;
}
new carid = PlayerInfo[playerid][pPcarkey3];
new Float:X, Float:Y, Float:Z;
new zone[MAX_ZONE_NAME];
GetVehicle2DZone(carid, zone, MAX_ZONE_NAME);
GetVehiclePos(carid, X,Y,Z);
if(Searching[playerid] == 0)
{
Searching[playerid] = 1;
SetPlayerCheckpoint(playerid, X,Y,Z, 5.0);
format(string, sizeof(string),"Checkpoint has been placed!",zone);
SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
}
else
{
SetPlayerCheckpoint(playerid, X,Y,Z, 5.0);
format(string, sizeof(string),"Checkpoint has been placed!",zone);
SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
}
}
else if(number == 4)
{
if(PlayerInfo[playerid][pPcarkey4] == 9999)
{
SendClientMessage(playerid, COLOR_GREY, "No Vehicle found in this slot 4");
return 1;
}
new carid = PlayerInfo[playerid][pPcarkey4];
new Float:X, Float:Y, Float:Z;
new zone[MAX_ZONE_NAME];
GetVehicle2DZone(carid, zone, MAX_ZONE_NAME);
GetVehiclePos(carid, X,Y,Z);
if(Searching[playerid] == 0)
{
Searching[playerid] = 1;
SetPlayerCheckpoint(playerid, X,Y,Z, 5.0);
format(string, sizeof(string),"Checkpoint has been placed!",zone);
SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
}
else
{
SetPlayerCheckpoint(playerid, X,Y,Z, 5.0);
format(string, sizeof(string),"Checkpoint has been placed!",zone);
SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
}
}
else if(number == 5)
{
if(PlayerInfo[playerid][pPcarkey5] == 9999)
{
SendClientMessage(playerid, COLOR_GREY, "No Vehicle found in this slot 5");
return 1;
}
new carid = PlayerInfo[playerid][pPcarkey5];
new Float:X, Float:Y, Float:Z;
new zone[MAX_ZONE_NAME];
GetVehicle2DZone(carid, zone, MAX_ZONE_NAME);
GetVehiclePos(carid, X,Y,Z);
if(Searching[playerid] == 0)
{
Searching[playerid] = 1;
SetPlayerCheckpoint(playerid, X,Y,Z, 5.0);
format(string, sizeof(string),"Checkpoint has been placed!",zone);
SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
}
else
{
SetPlayerCheckpoint(playerid, X,Y,Z, 5.0);
format(string, sizeof(string),"Checkpoint has been placed!",zone);
SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
}
}
}
}
but this 1 doesnt work
Re: findcar -
kepa333 - 21.06.2012
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?
Re: findcar -
kepa333 - 22.06.2012
any 1 ?
Re: findcar -
kepa333 - 23.06.2012
Its all about those lines ,
PHP код:
if(number < 1 || number > 2)
When i put it like this
PHP код:
if (number < 1 || number > 2 || number > 3 || number > 4 || number > 5)
It will only work For ID 1 -2
but when i put it like this
PHP код:
if(number < 1 || number < 2 || number < 3 || number < 4 || number < 5)
it will find 4-5 and others it wont
Please help XD
Re: findcar -
[MM]RoXoR[FS] - 23.06.2012
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.
Re: findcar -
leonardo1434 - 23.06.2012
try that..
it says.
number must be bigger than 0 and less or equal to 5.
pawn Код:
if (number > 0 || number <= 5)
Re: findcar -
kepa333 - 23.06.2012
Both of yours Doesnt work . Anyone?
Re: findcar -
Randy More - 23.06.2012
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].
AW: findcar -
Nero_3D - 23.06.2012
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);
}
Re: findcar -
kepa333 - 23.06.2012
Bro I already made it Work but Still thanks Ill keep this 1
Edit I forgot to give you rep LOL! here ya go