SA-MP Forums Archive
Name somehow seems to pass !strcmp while not the same - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Name somehow seems to pass !strcmp while not the same (/showthread.php?tid=253917)



Name somehow seems to pass !strcmp while not the same - Jochemd - 08.05.2011

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


Re: Name somehow seems to pass !strcmp while not the same - Jochemd - 09.05.2011

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.");
}



Re: Name somehow seems to pass !strcmp while not the same - MadeMan - 09.05.2011

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);



Re: Name somehow seems to pass !strcmp while not the same - Seven_of_Nine - 09.05.2011

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]


Re: Name somehow seems to pass !strcmp while not the same - Biesmen - 09.05.2011

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



Re: Name somehow seems to pass !strcmp while not the same - Jochemd - 09.05.2011

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.