Compare Name with part of an enum
#1

pawn Code:
for(new i; i<MAX_BUSINESS; i++)
    {
        GetPlayerName(playerid,Name,sizeof(Name));
        printf(BizInfo[i][Owner]);
        if(!strcmp(BizInfo[i][Owner],Name,true))
        {
            ShowPlayerDialog(playerid,DIALOG_BIZ,DIALOG_STYLE_LIST,"Verslo valdymas","Pakeisti biznio pavadinima\nPakeisti įėjimo kainą","Pasirinkti","Atsaukti");
        }
        else SendClientMessage(playerid,0xFF0000FF,"Tu neturi jokio verslo");
    }
Here is my script. The problem is, there's no BizInfo with my name,but i still see the dialog. Any help?
Reply
#2

pawn Code:
if(strcmp(BizInfo[i][Owner], Name, false) == 0)
Reply
#3

Quote:
Originally Posted by Ken97
View Post
pawn Code:
if(strcmp(BizInfo[i][Owner], Name, false) == 0)
pawn Code:
if(!strcmp(BizInfo[i][Owner],Name,true))
It's the same, the only one change in yours is case value.
Reply
#4

Quote:
Originally Posted by Riddick94
View Post
pawn Code:
if(!strcmp(BizInfo[i][Owner],Name,true))
It's the same, the only one change in yours is case value.
Very well then,

OT: How do you define your BizInfo?

EDIT: Also how do you load your user info onto the variable BizInfo[i][Owner]?
Reply
#5

pawn Code:
enum bInfo
{
    bizid,
    Owner[32],
    Owned,
    Price,
    BizName[64],
    Type,
    Products,
    EntrancePrice,
    Float:enX,
    Float:enY,
    Float:enZ,
    Float:exX,
    Float:exY,
    Float:exZ,
    Interior,
    VirtualWorld,
    Text3D:HouseLabel[24],
    Locked
};
new BizInfo[MAX_BUSINESS][bInfo];
EDIT: yes, i have a loadbussiness function,which loads it on game mode init.
Reply
#6

If any of the variables are blank, it will say that they matched.

pawn Code:
strsame(firstString[], secondString[], bool: caseSensitive = false)
{
    if(isnull(firstString) || isnull(secondString)) return 0;
    return !strcmp(firstString, secondString, caseSensitive);
}
Requires an isnull function which ZCMD automatically adds to your script. Usage:

pawn Code:
if(strsame("Hello", "Hello"))
That will return true.
Reply
#7

Thank you very much! Could have never though of that myself
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)