Index Problem
#1

Hello,

I am trying to setup a business system, but I want it to read the business to see if the player is the owner of the business so he can sell it if he wants to.

For some reason the way I do it doesn't work.

pawn Код:
new Confirmation[7], playername[MAX_PLAYER_NAME];
    GetPlayerName( playerid, playername, sizeof( playername ) );
    if( sscanf( params, "z", Confirmation) )
    {
        SendClientMessage( playerid, WHITE, "Are you SURE you want to abandon your business? Please type /abandonbusiness confirm" );
    }
    else
    {
        if(strcmp(Confirmation, "Confirm", true) == 0 )
        {
            for(new i = 0; i < sizeof(Businesses); i++)
            {
            if( IsPlayerInRangeOfPoint( playerid, 3, Businesses[i][bExteriorX], Businesses[i][bExteriorY], Businesses[i][bExteriorZ]) )
            {
            if( playername == Businesses[i][bOwner] ) )
            {
                format(Businesses[i][bOwner], 255, "Nobody" );
                Businesses[i][bLockStatus] = 1;
                SendClientMessage( playerid, WHITE, "You have now abandoned your business." );
                SaveBusiness(i);
                Player[playerid][Business] = Player[playerid][Business]-1;
                }
                }
            }
        }
    }
The Errors I get are listed below:


C:\Documents and Settings\Admin\Desktop\Vortex\VortexRoleplay\gamem odes\VortexRoleplay.pwn(12636) : error 033: array must be indexed (variable "playername")
C:\Documents and Settings\Admin\Desktop\Vortex\VortexRoleplay\gamem odes\VortexRoleplay.pwn(12636) : error 029: invalid expression, assumed zero
C:\Documents and Settings\Admin\Desktop\Vortex\VortexRoleplay\gamem odes\VortexRoleplay.pwn(12837) : warning 217: loose indentation
C:\Documents and Settings\Admin\Desktop\Vortex\VortexRoleplay\gamem odes\VortexRoleplay.pwn(12870) : warning 217: loose indentation
C:\Documents and Settings\Admin\Desktop\Vortex\VortexRoleplay\gamem odes\VortexRoleplay.pwn(28492) : warning 217: loose indentation
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


2 Errors.

Could anybody help me?
Reply
#2

You need to use strcmp, you can't just use the '==' operator for strings (that only works for integers/booleans).

pawn Код:
if(strcmp(playername, Businesses[i][bOwner], true) == 0)
Reply
#3

You also have too many brackets. Remove the first two brackets under "Player[playerid][Business] = Player[playerid][Business]-1;"
Reply
#4

or you can you Strmatch

much easier to understand and doesnt return 0 if its right<.<
pawn Код:
if(strcmp(playername, Businesses[i][bOwner])
pawn Код:
stock strmatch(const String1[], const String2[])//
{
    if ((strcmp(String1, String2, true, strlen(String2)) == 0) && (strlen(String2) == strlen(String1)))
    {
    return true;
    }
    else
    {
    return false;
    }
}
also did you just copy that out of vortex roleplay's business system because it looks "Very" familiar
Reply
#5

Well, the Business System, and House System are all based from Vortex Roleplay.
Mainly because I can't be F**K'd to rescript a whole business system, though their are alot of fixes in it.
And added things.
Reply


Forum Jump:


Users browsing this thread: