Check for string text?
#1

This is how I made it, but when I try to start vehicle owned by State, it tells me that I don't have a key's...

pawn Код:
CMD:start(playerid, params[])
{
    #pragma unused params
    new vid = GetPlayerVehicleID(playerid);
    if(GetPlayerState(playerid) == 2)
    {
        if(EngineStarted[vid] == 0)
        {
            if(vid != INVALID_VEHICLE_ID)
            {
                new name[MAX_PLAYER_NAME];

                if(strcmp(VehicleInfo[vid][vOwner], "State", true))
                {
                    SendClientMessage(playerid, coloryellow, "Starting vehicle engine...");
                    SetTimerEx("StartingEngine", 2500, false, "i", playerid);
             
                }
                else if(GetPlayerName(playerid, name, sizeof(name)) == VehicleInfo[vid][vOwner])
                {
                    SendClientMessage(playerid, coloryellow, "Starting vehicle engine...");
                    SetTimerEx("StartingEngine", 2500, false, "i", playerid);
             
                }
               
                else
                {
                    SendClientMessage(playerid, colorgrey, "You don't have a keys of this vehicle.");
                }

            }
        }
    }
    return 1;
}
Reply
#2

Try like this

pawn Код:
if(!strcmp(VehicleInfo[vid][vOwner], "State", true))
                {
                    SendClientMessage(playerid, coloryellow, "Starting vehicle engine...");
                    SetTimerEx("StartingEngine", 2500, false, "i", playerid);
             
                }
Reply
#3

Alright, that worked, but I cannot turn on owned vehicles now.

this part doesn't work now -.-
pawn Код:
else if(GetPlayerName(playerid, name, sizeof(name)) == VehicleInfo[vid][vOwner])
                {
                    SendClientMessage(playerid, coloryellow, "Starting vehicle engine...");
                    SetTimerEx("StartingEngine", 2500, false, "i", playerid);
             
                }
It is loaded correctly from file

pawn Код:
INI_String("Owner", VehicleInfo[vehicleID][vOwner], 32);
Reply
#4

Try this:

pawn Код:
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name);
else if(strcmp(name, VehicleInfo[vid][vOwner], true) == 0)
Reply
#5

pawn Код:
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name);
else if(strcmp(name, VehicleInfo[vid][vOwner], true) == 0)
same error dude --'
do like that ^^

pawn Код:
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name);
else if(!strcmp(name, VehicleInfo[vid][vOwner], true) == 0)
Reply
#6

Quote:
Originally Posted by Ramoboss
Посмотреть сообщение
pawn Код:
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name);
else if(strcmp(name, VehicleInfo[vid][vOwner], true) == 0)
same error dude --'
do like that ^^

pawn Код:
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name);
else if(!strcmp(name, VehicleInfo[vid][vOwner], true) == 0)
Why in the world do you have to put a "!" in it? If it should work perfectly how it is.
Reply
#7

pawn Код:
else if(!strcmp(name, VehicleInfo[vid][vOwner], true) == 0)
is the same as:
pawn Код:
if(!(!strcmp(name, VehicleInfo[vid][vOwner], true)))
The correct code would be:
pawn Код:
if(!strcmp(name, VehicleInfo[vid][vOwner], false))
Reply
#8

So basically your doing it backwards (same result but backwards). Why would you want to do it backwards?
pawn Код:
if(!strcmp(name, VehicleInfo[vid][vOwner], false))
This will work also:
pawn Код:
if(strcmp(name, VehicleInfo[vid][vOwner], true) == 0)
Reply
#9

They both mean the exact same thing. if(!var) is the same as if(var == 0).
Reply
#10

So why in the world would you want to do it backwards if you can do it forwards?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)