CMD problem?
#1

Error:
Код:
C:\Users\Hellman\Desktop\Rebound Roleplay server\pawno\include\/CRP/Commands/adminname.pwn(48) : warning 217: loose indentation
C:\Users\Hellman\Desktop\Rebound Roleplay server\pawno\include\/CRP/Commands/adminname.pwn(57) : warning 217: loose indentation
C:\Users\Hellman\Desktop\Rebound Roleplay server\pawno\include\/CRP/Commands/adminname.pwn(57) : error 029: invalid expression, assumed zero
C:\Users\Hellman\Desktop\Rebound Roleplay server\pawno\include\/CRP/Commands/adminname.pwn(61) : warning 209: function "cmd_setadminname" should return a value
C:\Users\Hellman\Desktop\Rebound Roleplay server\pawno\include\/CRP/Commands/adminname.pwn(62) : error 010: invalid function or declaration
pawn Код:
CMD:setadminname(playerid, params[]) {
    if(PlayerInfo[playerid][pAdministrator] >= 4) {
        new
            userID,
            playerNameString[MAX_PLAYER_NAME];

        if(sscanf(params, "us[24]", userID, playerNameString)) {
            return SendClientMessage(playerid, COLOR_GREY, "/setadminname [playerid] [adminname]");
        }
        else {
            if(!IsPlayerConnected(userID))
                return SendClientMessage(playerid, COLOR_GREY, "The specified player ID is either not connected or has not authenticated.");

            if(PlayerInfo[userID][pAdministrator] >= 1) {
                if(PlayerInfo[userID][pAdministrator] > PlayerInfo[playerid][pAdministrator]) {
                    return SendClientMessage(playerid, COLOR_GREY, "You can't change the admin name of a higher level administrator.");
                }
                else {
                    new
                        messageString[128];
                    new Query[128];
                    new result[80];
                    format( Query, sizeof( Query ), "SELECT * FROM `Accounts` WHERE `Adminname` = '%s'", (result) );
                    mysql_query( Query );
                    printf(" SQL: %s",Query);
                    mysql_store_result();
                    if( mysql_num_rows() >= 1 )
                    {
                        mysql_free_result();
                        SendClientMessage( playerid, COLOR_WHITE, "This username is already taken, tell him to take another one." );
                        return 1;
                    } else {
                        mysql_free_result();
                    }

                    format(messageString, sizeof(messageString), "You have changed %s's admin name to %s.", PlayerInfo[userID][AdminName], playerNameString);
                    SendClientMessage(playerid, COLOR_WHITE, messageString);

                    format(messageString, sizeof(messageString), "%s has changed your admin name to %s.", PlayerInfo[playerid][AdminName], playerNameString);
                    SendClientMessage(userID, COLOR_WHITE, messageString);

                    format(PlayerInfo[userID][AdminName], MAX_PLAYER_NAME, "%s", playerNameString);

                    if(AdminDuty[playerid] >= 1)
                        SetPlayerName(userID, playerNameString);
                    }
                    // More stupid shit
                    new string[128];
                    new result[80];
                    new giveplayerid;
                    SetPlayerName(giveplayerid,(result));
                    format( string, sizeof( string ), "UPDATE `Accounts` SET `AdminName` = '%s' WHERE `UserID` = '%d'",(result),PlayerInfo[ giveplayerid ][pDatabaseID]);
                    mysql_query(string);
                    return 1;
                }
            }
            else {
                return SendClientMessage(playerid, COLOR_GREY, "You can't change a non-admin's admin name.");
            }
        }
    }
    return 1;
}
Reply
#2

Your BRACKETS
Reply
#3

Use Tidypawn/Autoindent. Here's the link http://dracoblue.net/tidy/pawn/
Reply
#4

Your brackets are missplaced, like pretty much every other problem I encounter here on forums.
So fix those OR
Код:
COMMAND:setadminname(playerid, params[])
{
	if(PlayerInfo[playerid][pAdmin] >= 4)
	{
	    new targetid, targetNAME[MAX_PLAYER_NAME];
	    if(!sscanf(params, "us", targetid, targetNAME))
	    {
	        if(targetid == INVALID_PLAYER_ID)
	        {
	            if(PlayerInfo[targetid][pAdmin] != PlayerInfo[playerid][pAdmin])
	            {
	                SetPlayerName(targetid, targetNAME);
	                // now you create strings, and send messages to both ends.
	            }
	        }
	    }
	}
	return 1;
}
Reply
#5

Try this
pawn Код:
CMD:setadminname(playerid, params[])
{
    if(PlayerInfo[playerid][pAdministrator] < 4)
        return true;

    new
        userID,
        playerNameString[MAX_PLAYER_NAME];

    if(sscanf(params, "us[24]", userID, playerNameString))
        return SendClientMessage(playerid, COLOR_GREY, "/setadminname [playerid] [adminname]");

    if(!IsPlayerConnected(userID))
        return SendClientMessage(playerid, COLOR_GREY, "The specified player ID is either not connected or has not authenticated.");

    if(PlayerInfo[userID][pAdministrator] >= 1)
        return SendClientMessage(playerid, COLOR_GREY, "You can't change a non-admin's admin name.");
    if(PlayerInfo[userID][pAdministrator] > PlayerInfo[playerid][pAdministrator])
        return SendClientMessage(playerid, COLOR_GREY, "You can't change the admin name of a higher level administrator.");

    new
        messageString[128];
    new Query[128];
    new result[80];
    format( Query, sizeof( Query ), "SELECT * FROM `Accounts` WHERE `Adminname` = '%s'", (result) );
    mysql_query( Query );
    printf(" SQL: %s",Query);
    mysql_store_result();
    if( mysql_num_rows() >= 1 )
    {
        mysql_free_result();
        SendClientMessage( playerid, COLOR_WHITE, "This username is already taken, tell him to take another one." );
        return 1;
    }
    else
        mysql_free_result();

    format(messageString, sizeof(messageString), "You have changed %s's admin name to %s.", PlayerInfo[userID][AdminName], playerNameString);
    SendClientMessage(playerid, COLOR_WHITE, messageString);

    format(messageString, sizeof(messageString), "%s has changed your admin name to %s.", PlayerInfo[playerid][AdminName], playerNameString);
    SendClientMessage(userID, COLOR_WHITE, messageString);

    format(PlayerInfo[userID][AdminName], MAX_PLAYER_NAME, "%s", playerNameString);

    if(AdminDuty[playerid] >= 1)
        SetPlayerName(userID, playerNameString);

    // More stupid shit
    new string[128];
    new result[80];
    new giveplayerid;
    SetPlayerName(giveplayerid,(result));
    format( string, sizeof( string ), "UPDATE `Accounts` SET `AdminName` = '%s' WHERE `UserID` = '%d'",(result),PlayerInfo[ giveplayerid ][pDatabaseID]);
    mysql_query(string);
    return 1;
}
Reply
#6

Quote:
Originally Posted by Viniborn
Посмотреть сообщение
Try this
pawn Код:
CMD:setadminname(playerid, params[])
{
    if(PlayerInfo[playerid][pAdministrator] < 4)
        return true;

    new
        userID,
        playerNameString[MAX_PLAYER_NAME];

    if(sscanf(params, "us[24]", userID, playerNameString))
        return SendClientMessage(playerid, COLOR_GREY, "/setadminname [playerid] [adminname]");

    if(!IsPlayerConnected(userID))
        return SendClientMessage(playerid, COLOR_GREY, "The specified player ID is either not connected or has not authenticated.");

    if(PlayerInfo[userID][pAdministrator] >= 1)
        return SendClientMessage(playerid, COLOR_GREY, "You can't change a non-admin's admin name.");
    if(PlayerInfo[userID][pAdministrator] > PlayerInfo[playerid][pAdministrator])
        return SendClientMessage(playerid, COLOR_GREY, "You can't change the admin name of a higher level administrator.");

    new
        messageString[128];
    new Query[128];
    new result[80];
    format( Query, sizeof( Query ), "SELECT * FROM `Accounts` WHERE `Adminname` = '%s'", (result) );
    mysql_query( Query );
    printf(" SQL: %s",Query);
    mysql_store_result();
    if( mysql_num_rows() >= 1 )
    {
        mysql_free_result();
        SendClientMessage( playerid, COLOR_WHITE, "This username is already taken, tell him to take another one." );
        return 1;
    }
    else
        mysql_free_result();

    format(messageString, sizeof(messageString), "You have changed %s's admin name to %s.", PlayerInfo[userID][AdminName], playerNameString);
    SendClientMessage(playerid, COLOR_WHITE, messageString);

    format(messageString, sizeof(messageString), "%s has changed your admin name to %s.", PlayerInfo[playerid][AdminName], playerNameString);
    SendClientMessage(userID, COLOR_WHITE, messageString);

    format(PlayerInfo[userID][AdminName], MAX_PLAYER_NAME, "%s", playerNameString);

    if(AdminDuty[playerid] >= 1)
        SetPlayerName(userID, playerNameString);

    // More stupid shit
    new string[128];
    new result[80];
    new giveplayerid;
    SetPlayerName(giveplayerid,(result));
    format( string, sizeof( string ), "UPDATE `Accounts` SET `AdminName` = '%s' WHERE `UserID` = '%d'",(result),PlayerInfo[ giveplayerid ][pDatabaseID]);
    mysql_query(string);
    return 1;
}
Thank you.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)