Who owns what car?
#3

pawn Код:
new Owner[128] = CarInfo[idx][cOwner]; // Why do you create a string[128] for inserting one of size 32? Also why declare this at all? Just a waste of resources. Use it directly for optimization.
         GetPlayerName(playerid, name, sizeof(name));
        if(Owner == name) // You need to use strcmp to compare strings, you cannot use ==. Also, you want to use != to evict them if they DON'T own the vehicle
        {
        SendClientMessage(playerid, COLOR_RED, "YOU DO NOT OWN THIS CAR");
                // This would be a good place to use RemovePlayerFromVehicle.
        return 0; // You don't want to return 0 here. Return 1.
        }
Meaning your code should look somewhat like this:

pawn Код:
GetPlayerName(playerid, name, sizeof(name));
if(strcmp(CarInfo[idx][cOwner], name, false) != 0)
{
    SendClientMessage(playerid, COLOR_RED, "YOU DO NOT OWN THIS CAR");
    RemovePlayerFromVehicle(playerid);
    return 1;
}
Reply


Messages In This Thread
Who owns what car? - by jeffery30162 - 13.03.2014, 01:26
Re: Who owns what car? - by nmader - 13.03.2014, 01:42
Re: Who owns what car? - by Ceathor - 13.03.2014, 01:51
Re: Who owns what car? - by jeffery30162 - 13.03.2014, 22:19

Forum Jump:


Users browsing this thread: 1 Guest(s)