Name somehow seems to pass !strcmp while not the same
#1

Hello,

I got a weird problem. While the 'Owner' in the file is set as 'Ashley Jennings' and I try to set the fee (my name is: Jeff Venturas) I can just do that. It just sees name as the same. Why is that?
pawn Код:
dcmd_parkfee(playerid,params[])
{
    new p = IsNearParkingLot(playerid);
    if(p != -1)
    {
        new Playername[MAX_PLAYER_NAME],filepl[30];
        GetPlayerRPName(playerid,Playername,sizeof(Playername));
        format(filepl,sizeof(filepl),"Stuff/ParkingLots/%d.ini",p);
        if(!strcmp(Playername,dini_Get(filepl,"Owner"),false))
        {
            new price;
            if(!sscanf(params,"d",price))
            {
                if(price >= 0 && price <= 100)
                {
                    new string[65];
                    ParkingLotInfo[p][Fee] = price;
                    dini_IntSet(filepl,"Fee",price);
                    format(string,sizeof(string),"  You have successfully changed the Parking Lot's Fee to $%d.",price);
                    SendClientMessage(playerid,COLOR_WHITE,string);
                    return 1;
                }
                else return SendClientMessage(playerid,COLOR_RED,"Maybe it is better to put a lower price or we get inflation...");
            }
            else return SendClientMessage(playerid,COLOR_RED,"Syntax Error: /parkfee [fee].");
        }
        else return SendClientMessage(playerid,COLOR_RED,"  You don't own this Parking Lot.");
    }
    else return SendClientMessage(playerid,COLOR_RED,"You are not near any Company.");
}
Hope to hear soon
Jochem
Reply
#2

Here's a small code update... Same result though

pawn Код:
dcmd_parkfee(playerid,params[])
{
    new p = IsNearParkingLot(playerid);
    if(p != -1)
    {
        new Playername[MAX_PLAYER_NAME],filepl[30],Ownername[MAX_PLAYER_NAME];
        GetPlayerRPName(playerid,Playername,sizeof(Playername));
        format(Ownername,sizeof(Ownername),"%s",ParkingLotInfo[p][Owner]);
        if(!strcmp(Playername,Ownername,false))
        {
            new price;
            if(!sscanf(params,"d",price))
            {
                if(price >= 0 && price <= 100)
                {
                    new string[65];
                    ParkingLotInfo[p][Fee] = price;
                    format(filepl,sizeof(filepl),"Stuff/ParkingLots/%d.ini",p);
                    dini_IntSet(filepl,"Fee",price);
                    format(string,sizeof(string),"  You have successfully changed the Parking Lot's Fee to $%d.",price);
                    SendClientMessage(playerid,COLOR_WHITE,string);
                    return 1;
                }
                else return SendClientMessage(playerid,COLOR_RED,"Maybe it is better to put a lower price or we get inflation...");
            }
            else return SendClientMessage(playerid,COLOR_RED,"Syntax Error: /parkfee [fee].");
        }
        else return SendClientMessage(playerid,COLOR_RED,"  You don't own this Parking Lot.");
    }
    else return SendClientMessage(playerid,COLOR_RED,"You are not near any Company.");
}
Reply
#3

Use printf to see what Playername and Ownername are.

pawn Код:
new Playername[MAX_PLAYER_NAME],filepl[30],Ownername[MAX_PLAYER_NAME];
GetPlayerRPName(playerid,Playername,sizeof(Playername));
format(Ownername,sizeof(Ownername),"%s",ParkingLotInfo[p][Owner]);
printf("Playername=|%s|     Ownername=|%s|", Playername,Ownername);
Reply
#4

I would check the files. Maybe somethings wrong there.
By the way I have the same problem with dini_Get. Idk what's that.

[off]Now I remember you You teached me how to use that MAX_PLAYERS. Well, I'm going to host a server soonly. Thanks for your inspirating help! xD[/off]
Reply
#5

Try using
pawn Код:
if(strcmp(PlayerName, OwnerName, false) == 0)
Reply
#6

Since ! is the same as == 0 it won't make any difference, but I will try. Always try.

Quote:
Originally Posted by Seven_of_Nine
Посмотреть сообщение
[off]Now I remember you You teached me how to use that MAX_PLAYERS. Well, I'm going to host a server soonly. Thanks for your inspirating help! xD[/off]
I am (almost) always open for any help

Edit: Playername returns my name, Ownername returns nothing. Guess there's something wrong in dini_Get.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)