problem with two commands
#1

Can you help me with /hire command, there's a problem but I don't know exact where.. tried everything, the command just says "Unknown command" and also my /fire command, working only on id 0, uh im confused xD

Код:
CMD:hire(playerid,params[])
{
	new
		string[256],
		id,
		faction[64],
		targetid
	;
 	if(ProxDetectorS(6.0, playerid, targetid))
    {
	if(plInfo[playerid][pRank] == 6 && plInfo[playerid][pMember] != TEAM_CIVILIAN) return 1;
	if(id == INVALID_PLAYER_ID) return GameTextForPlayer(playerid, "~n~~n~~n~~n~~n~Player is not connected.", 3000, 5);
	else if(sscanf(params, "u", id)) return SendClientMessage(playerid, COLOR_GREY, "Usage: /hire [id/name]");
	else if(plInfo[id][pMember] != TEAM_CIVILIAN) return  GameTextForPlayer(playerid, "The player is hired already.", 3000, 5);

	format(faction, sizeof(faction), TeamInfo[plInfo[playerid][pMember]][TeamName]);
	format(string, sizeof(string), "You have been hired in %s", faction);
	SendClientMessage(playerid, COLOR_BLUE, string);
	plInfo[playerid][pRank] = 1;
	plInfo[playerid][pMember] = plInfo[playerid][pMember];
	gTeam[playerid] = plInfo[playerid][pMember];
	SetPlayerSpawn(playerid);
	SaveFactions();
	} else {
	GameTextForPlayer(playerid, "~n~~n~~n~~n~~n~You aren't enough nearly to him", 3000, 5);
	}
	return 1;
}
Код:
CMD:fire(playerid,params[])
{
	new
		string[256],
		id,
		faction[64],
		targetid
	;
	if(ProxDetectorS(6.0, playerid, targetid))
    {
	if(plInfo[playerid][pRank] == 6 && plInfo[playerid][pMember] != TEAM_CIVILIAN) return 1;
	if(id == INVALID_PLAYER_ID) return GameTextForPlayer(playerid, "~n~~n~~n~~n~~n~Player is not connected.", 3000, 5);
	else if(sscanf(params, "u", id)) return SendClientMessage(playerid, COLOR_GREY, "Usage: /fire [id/name]");

	format(faction, sizeof(faction), TeamInfo[plInfo[playerid][pMember]][TeamName]);
	format(string, sizeof(string), "You have been fired from %s", faction);
	SendClientMessage(playerid, COLOR_BLUE, string);
	plInfo[playerid][pRank] = 0;
	plInfo[playerid][pMember] = TEAM_CIVILIAN;
	gTeam[playerid] = TEAM_CIVILIAN;
	SetPlayerSpawn(playerid);
	SaveFactions();
	} else {
	GameTextForPlayer(playerid, "~n~~n~~n~~n~~n~You aren't enough nearly to him", 3000, 5);
	}
	return 1;
}
Reply
#2

Hmm, about the else if(sscanf the way you create sscanf is wrong. always start with if when making sscanf (( sorry if im bad in explaining ))

pawn Код:
CMD:hire(playerid,params[])
{
    new
        string[256],
        id,
        faction[64],
        targetid;
    if(sscanf(params, "u", id)) return SendClientMessage(playerid, COLOR_GREY, "Usage: /hire [id/name]");
    if(ProxDetectorS(6.0, playerid, targetid))
    {
        if(plInfo[playerid][pRank] == 6 && plInfo[playerid][pMember] != TEAM_CIVILIAN) return 1;
        if(id == INVALID_PLAYER_ID) return GameTextForPlayer(playerid, "~n~~n~~n~~n~~n~Player is not connected.", 3000, 5);
        if(plInfo[id][pMember] != TEAM_CIVILIAN) return  GameTextForPlayer(playerid, "The player is hired already.", 3000, 5);

        format(faction, sizeof(faction), TeamInfo[plInfo[playerid][pMember]][TeamName]);
        format(string, sizeof(string), "You have been hired in %s", faction);
        SendClientMessage(playerid, COLOR_BLUE, string);
        plInfo[playerid][pRank] = 1;
        plInfo[playerid][pMember] = plInfo[playerid][pMember];
        gTeam[playerid] = plInfo[playerid][pMember];
        SetPlayerSpawn(playerid);
        SaveFactions();
    }
    else
    {
        GameTextForPlayer(playerid, "~n~~n~~n~~n~~n~You aren't enough nearly to him", 3000, 5);
    }
    return 1;
}
CMD:fire(playerid,params[])
{
    new
        string[256],
        id,
        faction[64],
        targetid
    ;
    if(sscanf(params, "u", id)) return SendClientMessage(playerid, COLOR_GREY, "Usage: /fire [id/name]");

    if(ProxDetectorS(6.0, playerid, targetid))
    {
        if(plInfo[playerid][pRank] == 6 && plInfo[playerid][pMember] != TEAM_CIVILIAN) return 1;
        if(id == INVALID_PLAYER_ID) return GameTextForPlayer(playerid, "~n~~n~~n~~n~~n~Player is not connected.", 3000, 5);

        format(faction, sizeof(faction), TeamInfo[plInfo[playerid][pMember]][TeamName]);
        format(string, sizeof(string), "You have been fired from %s", faction);
        SendClientMessage(playerid, COLOR_BLUE, string);
        plInfo[playerid][pRank] = 0;
        plInfo[playerid][pMember] = TEAM_CIVILIAN;
        gTeam[playerid] = TEAM_CIVILIAN;
        SetPlayerSpawn(playerid);
        SaveFactions();
    }
    else
    {
        GameTextForPlayer(playerid, "~n~~n~~n~~n~~n~You aren't enough nearly to him", 3000, 5);
    }
    return 1;
}
Reply
#3

Mhm, thanks, now I can type them, but they both does not work. Can someone fix the commands?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)