Only taking id0 even if i type id 1
#1

Hello, when i set gate owner and we are two, or more online
i can only set Id 0 as the owner, even if i type the name of id 2, it just says "id 0 is already the owner
what is wrong?

pawn Код:
if (dialogid == DIALOG_NEWGOWNER)
    {
        if (response)
        {
            new ostring[MAX_PLAYER_NAME], astring[128];
            strcpy(ostring, gowner[gsaveid[playerid]]);
            //new plid;
            if (sscanf(inputtext, "u", playerid)) SendClientMessage(playerid, -1, ""COL_RED"Invalid Player ID/Name");
            else if (playerid == INVALID_PLAYER_ID) SendClientMessage(playerid, -1, ""COL_RED"Invalid Player");
            else
            {
                new pname[MAX_PLAYER_NAME];
                GetPlayerName(playerid, pname, MAX_PLAYER_NAME);
                if(!strcmp(gowner[gsaveid[playerid]], pname))
                {
                    format(astring, 128, ""COL_WHITE"%s is already the owner of the gate %i", pname, gsaveid[playerid]);
                    SendClientMessage(playerid, -1, astring);
                }
                else
                {
                    new INI:gatefile = INI_Open(GateINI(gsaveid[playerid]));
                    INI_SetTag(gatefile, "data");
                    INI_WriteString(gatefile, "owner", pname);
                    INI_Close(gatefile);
                    if (!strcmp(ostring, "none")) format(astring, 128, ""COL_GREEN"You have set %s to be the owner of the gate %i.", pname, gsaveid[playerid]);
                    else format(astring, 128, ""COL_GREEN"%s is no longer the owner of the gate %i. %s is the new owner", ostring, gsaveid[playerid], pname);
                    SendClientMessage(playerid, -1, astring);
                }
            }
        }
    }
Reply
#2

Sorry i have put the wrong code, its the right one now ^^
Reply
#3

Well, can you say how you fixed it?
Reply
#4

Use something other than playerid.
Create a new variable like 'targetid' or something.
Reply
#5

Quote:
Originally Posted by XtremeRz
Посмотреть сообщение
Well, can you say how you fixed it?
I have not fixed it yet 😊
Reply
#6

Anyone?
Reply
#7

I tried to make this but it gives me errors when im compiling

pawn Код:
if (dialogid == DIALOG_NEWGOWNER)
    {
        if (response)
        {
            new ostring[MAX_PLAYER_NAME], astring[128];
            strcpy(ostring, gowner[gsaveid[playerid]]);
            //new plid;
            if (sscanf(inputtext, "u", playerid)) SendClientMessage(playerid, -1, ""COL_RED"Invalid Player ID/Name");
            else if (playerid == INVALID_PLAYER_ID) SendClientMessage(playerid, -1, ""COL_RED"Invalid Player");
            else
            {
                //new pname[MAX_PLAYER_NAME];
                new targetid = ReturnUser(inputtext);
                GetPlayerName(playerid, targetid, MAX_PLAYER_NAME);
                if(!strcmp(gowner[gsaveid[playerid]], targetid))
                {
                    format(astring, 128, ""COL_WHITE"%s is already the owner of the gate %i", targetid, gsaveid[playerid]);
                    SendClientMessage(playerid, -1, astring);
                }
                else
                {
                    new INI:gatefile = INI_Open(GateINI(gsaveid[playerid]));
                    INI_SetTag(gatefile, "data");
                    INI_WriteString(gatefile, "owner", targetid);
                    INI_Close(gatefile);
                    if (!strcmp(ostring, "none")) format(astring, 128, ""COL_GREEN"You have set %s to be the owner of the gate %i.", targetid, gsaveid[playerid]);
                    else format(astring, 128, ""COL_GREEN"%s is no longer the owner of the gate %i. %s is the new owner", ostring, gsaveid[playerid], targetid);
                    SendClientMessage(playerid, -1, astring);
                }
            }
        }
    }
Reply
#8

what error? and the code you put is logically wrong too
Reply
#9

Can you help me how to fix it please?

pawn Код:
error 035: argument type mismatch (argument 2)
 error 035: argument type mismatch (argument 2)
error 035: argument type mismatch (argument 3)
Reply
#10

PHP код:
if (dialogid == DIALOG_NEWGOWNER)
    {
        if (
response)
        {
            new 
ostring[MAX_PLAYER_NAME], astring[128];
            
strcpy(ostringgowner[gsaveid[playerid]]);
            new 
plid;
            if (
sscanf(inputtext"u"plid)) SendClientMessage(playerid, -1""COL_RED"Invalid Player ID/Name");
            else if (
playerid == INVALID_PLAYER_IDSendClientMessage(playerid, -1""COL_RED"Invalid Player");
            else
            {
                new 
pname[MAX_PLAYER_NAME];
                
GetPlayerName(plidpnameMAX_PLAYER_NAME);
                if(!
strcmp(gowner[gsaveid[plid]], pname))
                {
                       
format(astring128""COL_WHITE"%s is already the owner of the gate %i"pnamegsaveid[playerid]);
                       
SendClientMessage(playerid, -1astring);
                }
                else
                {
                    new 
INI:gatefile INI_Open(GateINI(gsaveid[playeridd]));
                    
INI_SetTag(gatefile"data");
                    
INI_WriteString(gatefile"owner"pname);
                    
INI_Close(gatefile);
                    if (!
strcmp(ostring"none")) format(astring128""COL_GREEN"You have set %s to be the owner of the gate %i."pnamegsaveid[playerid]);
                    else 
format(astring128""COL_GREEN"%s is no longer the owner of the gate %i. %s is the new owner"ostringgsaveid[playerid], pname);
                    
SendClientMessage(playerid, -1astring);
                }
            }
        }
    } 
try them
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)