Help - How Would I Do This?
#1

So I am creating a house system, I need to see if the player's name equals the owner of the house. I have This...
pawn Код:
if(pName[playerid] == hOwner[hid]) {
And I Get This...
Quote:

error 033: array must be indexed (variable "pName")


I also have tried this...
pawn Код:
if(strcmp(hOwner[hid], pName[playerid], true)) {
I get no error but it doesn't work in-game. Because the person who owns the house can't do it.

What is the proper way to do this?
Reply
#2

Код:
new pname[MAX_PLAYER_NAME], string[39 + MAX_PLAYER_NAME];
    GetPlayerName(playerid, pname, sizeof(pname));
    if(pname[playerid] == hOwner[hid])
    {
SendClientMessage(playerid,COLOR_,"OHAI");
    }
Reply
#3

I have already tried this. Did you look at my code.

These are the global variables used in the if statements...
pawn Код:
//These Are Up Top
new pName[MAX_PLAYERS][MAX_PLAYER_NAME];
new hOwner[MAX_HOUSES];

//These Are Used In If Statments
GetPlayerName(playerid, pName[playerid], MAX_PLAYER_NAME);
hOwner[hid] = dini_Int(hFile[hid], "hOwner");
Reply
#4

Quote:
Originally Posted by Tim_Ethen
Посмотреть сообщение
So I am creating a house system, I need to see if the player's name equals the owner of
pawn Код:
if(strcmp(hOwner[hid], pName[playerid], true)) {
I get no error but it doesn't work in-game. Because the person who owns the house can't do it.

What is the proper way to do this?
strcmp returns 0 if the Strings are Equal, so you must do

pawn Код:
if(!strcmp(hOwner[hid], pName[playerid], true)) {
Reply
#5

This Doesn't Work Either. Now anybody can do it.
pawn Код:
if(strcmp("/lock", cmdtext, true, 5) == 0) {
        new hid = 0;
        while(hid < MAX_HOUSES) {
            if(IsPlayerInRangeOfPoint(playerid, 5, hPickupX[hid], hPickupY[hid], hPickupZ[hid]) == 1) {
                if(!strcmp(pName[playerid], hOwner[hid], true)) {
                    hLock[hid] = 1;
                    SendClientMessage(playerid, yellow, "Your House Was Locked");
                }
                else SendClientMessage(playerid, yellow, "You Can't Lock This House");
                break;
            }
            hid++;
        }
        return 1;
    }
   
    if(strcmp("/unlock", cmdtext, true, 7) == 0) {
        new hid = 0;
        while(hid < MAX_HOUSES) {
            if(IsPlayerInRangeOfPoint(playerid, 5, hPickupX[hid], hPickupY[hid], hPickupZ[hid]) == 1) {
                if(!strcmp(pName[playerid], hOwner[hid], true)) {
                    hLock[hid] = 0;
                    SendClientMessage(playerid, yellow, "Your House Was Unlocked");
                }
                else SendClientMessage(playerid, yellow, "You Can't Unlock This House");
                break;
            }
            hid++;
        }
        return 1;
    }
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)