What am I doing wrong?
#1

-- 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.
Reply
#2

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?
Reply
#3

Nope, and I've provided a screenshot.

Reply
#4

Check the defined place on Maximum_Vehicles
MAXIMUM_VEHICLES; v++ )
There is problem I guess.
Reply
#5

That's not the problem, unfortunately. It's strcmp.
Reply
#6

Yeah he's right! You didn't define it, did you?

pawn Код:
//example
new vehicleamount[MAX_VEHICLES];
Reply
#7

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)
Reply
#8

Код:
new vcount = 0;
Put that on top of your gamemode/filterscript.
Reply
#9

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
Reply
#10

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;
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)