What am I doing wrong? -
2KY - 16.02.2012
-- The original code was correct, my NAME was the issue due to my name having a numerical value first (
2KY) it bugged due to variables not being allowed to have a number first. E.G: new 2KNOS; would yield an error, I should have realized this from back when I made 2KNOS.
Re: What am I doing wrong? -
Twisted_Insane - 16.02.2012
Shouldn't it be the negative?
pawn Код:
if(!strcmp(vehInfo[v][Owner], p_Name, false) == 0)
I never worked with "strcmp", sorry, hate it!^^ What exactly is wrong with your cmd?
Re: What am I doing wrong? -
2KY - 16.02.2012
Nope, and I've provided a screenshot.
Re: What am I doing wrong? -
Smacky - 16.02.2012
Check the defined place on Maximum_Vehicles
MAXIMUM_VEHICLES; v++ )
There is problem I guess.
Re: What am I doing wrong? -
2KY - 16.02.2012
That's not the problem, unfortunately. It's strcmp.
Re: What am I doing wrong? -
Twisted_Insane - 16.02.2012
Yeah he's right! You didn't define it, did you?
pawn Код:
//example
new vehicleamount[MAX_VEHICLES];
Re: What am I doing wrong? -
2KY - 16.02.2012
MAXIMUM_VEHICLES is defined the same way as my faction system, and both of which work perfectly fine; this is not the issue. I assure you.
pawn Код:
#define MAX_FACTIONS 101
#define MAXIMUM_VEHICLES 101
I almost guarentee the problem line is
pawn Код:
if(strcmp(vehInfo[v][Owner], p_Name, false) == 0)
Re: What am I doing wrong? -
Shetch - 16.02.2012
Put that on top of your gamemode/filterscript.
Re: What am I doing wrong? -
dice7 - 16.02.2012
The strcmp is fine. Do this
Код:
SendClientMessage(playerid, 0xAAAAAA, vehInfo[v][Owner]);
if(strcmp(vehInfo[v][Owner], p_Name, false) == 0)
to check if the string is not empty. If it is, then strcmp will also return 0
Re: What am I doing wrong? -
2KY - 16.02.2012
Quote:
Originally Posted by dice7
The strcmp is fine. Do this
Код:
SendClientMessage(playerid, 0xAAAAAA, vehInfo[v][Owner]);
if(strcmp(vehInfo[v][Owner], p_Name, false) == 0)
to check if the string is not empty. If it is, then strcmp will also return 0
|
Quote:
[18:58:40] 2KY
[18:58:40] None
[18:58:40] 2KY
[18:58:40] 2KY
[18:58:40] 2KY
[18:58:40] 2KY
|
Which is correct for all of my vehicles. It just doesn't compare them correctly and send me a message.
What I want it to do:
Scan through all of the available vehicles, if the vehicles owner matches their name, then send them a message and increase vcount. It SHOULD work, however, it doesn't.
pawn Код:
CMD:myvehicles(playerid, params[])
{
new
p_Name[MAX_PLAYER_NAME],
vehStr[128],
vcount = 0
;
GetPlayerName(playerid, p_Name, 24);
for( new v = 1; v < MAXIMUM_VEHICLES; v++ ) //Loop through all the vehicles
{
SendClientMessage(playerid, 0xAAAAAA, vehInfo[v][Owner]);
if(strcmp(vehInfo[v][Owner], p_Name, false) == 0)
{
format(vehStr, sizeof(vehStr), ""#LIME"» "#WHITE"%d", v);
//SendClientMessage(playerid, -1, vehStr);
vcount++;
}
}
format(vehStr, sizeof(vehStr), "* Total owned vehicles: "#LIME"%d", vcount);
SendClientMessage(playerid, -1, vehStr);
return true;
}