How to check if string1 = string2?
#1

Hey everyone,

Maybe I'm kinda dumb, but I don't really know how to check if string1 = string2.

This is how I do:
Quote:

new IsOwner[20];
GetPlayerName(playerid, IsOwner, sizeof(IsOwner));

if(CarInfo[vehicleid][owner] = IsOwner)
{
SendClientMessage(playerid, 0xFFFFFFFF, "This is your vehicle.");
}
else
{
SendClientMessage(playerid, 0xFFFFFFFF, "You don't own this vehicle!");
RemovePlayerFromVehicle(playerid);
}

But it doesn't really work. When I try to sit into the car it allways says: "This is your vehicle" and let's me drive.
This is what compilier gives:
Quote:

...\car.pwn(125) : warning 211: possibly unintended assignment

Can anyone help me, please?
Reply
#2

https://sampwiki.blast.hk/wiki/Strcmp
Reply
#3

Use strcmp.
Reply
#4

You can use this convenient function:
pawn Код:
stock strmatch(const String1[], const String2[])
{
    if ((strcmp(String1, String2, true, strlen(String2)) == 0) && (strlen(String2) == strlen(String1)))
    {
        return true;
    }
    else
    {
        return false;
    }
}
pawn Код:
if(strmatch(CarInfo[vehicleid][owner], IsOwner))
{
    // Names match
}
Reply
#5

Thanks You guys.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)