SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Help Archive

 
 
Thread Tools Display Modes
Old 08/05/2011, 04:02 PM   #1
Jochemd
High-roller
 
Jochemd's Avatar
 
Join Date: Jul 2009
Location: The Netherlands
Posts: 2,220
Reputation: 844
Default Name somehow seems to pass !strcmp while not the same

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 Code:
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
__________________
Jochemd is offline  
Old 09/05/2011, 07:18 PM   #2
Jochemd
High-roller
 
Jochemd's Avatar
 
Join Date: Jul 2009
Location: The Netherlands
Posts: 2,220
Reputation: 844
Default Re: Name somehow seems to pass !strcmp while not the same

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

pawn Code:
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.");
}
__________________
Jochemd is offline  
Old 09/05/2011, 07:23 PM   #3
MadeMan
High-roller
 
MadeMan's Avatar
 
Join Date: Jun 2007
Posts: 3,488
Reputation: 256
Default Re: Name somehow seems to pass !strcmp while not the same

Use printf to see what Playername and Ownername are.

pawn Code:
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);
MadeMan is offline  
Old 09/05/2011, 07:24 PM   #4
Seven_of_Nine
Huge Clucker
 
Seven_of_Nine's Avatar
 
Join Date: Feb 2011
Location: Hungary
Posts: 372
Reputation: 12
Default Re: Name somehow seems to pass !strcmp while not the same

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]
__________________
- seven
Seven_of_Nine is offline  
Old 09/05/2011, 07:24 PM   #5
Biesmen
High-roller
 
Biesmen's Avatar
 
Join Date: May 2009
Posts: 1,058
Reputation: 665
Default Re: Name somehow seems to pass !strcmp while not the same

Try using
pawn Code:
if(strcmp(PlayerName, OwnerName, false) == 0)
Biesmen is offline  
Old 09/05/2011, 07:25 PM   #6
Jochemd
High-roller
 
Jochemd's Avatar
 
Join Date: Jul 2009
Location: The Netherlands
Posts: 2,220
Reputation: 844
Default Re: Name somehow seems to pass !strcmp while not the same

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 View Post
[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.
__________________
Jochemd is offline  
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
pass change fissekarl Help Archive 8 07/04/2011 09:06 PM
can we put a pass on amx joec39 Help Archive 2 24/06/2010 06:51 PM
car pass ivex Help Archive 0 09/02/2010 06:27 PM
door pass ivex Help Archive 2 05/02/2010 09:46 PM
Rcon pass radi Help Archive 9 29/11/2009 05:08 PM


All times are GMT. The time now is 01:52 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.