Small problem
#1

Keeps saying ''USAGE: /unjail [playerid/PartOfName]", I probaly don't see what I did wrong because I didn't sleep for 2 days. Could anyone please help. Thanks!

Код:
			if(strcmp(cmd, "/unjail", true) == 0)
	{
	    if(IsPlayerConnected(playerid))
	    {
			tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, COLOR_WHITE, "USAGE: /unjail [playerid/PartOfName]");
				return 1;
			}
			new giveplayerid;
			giveplayerid = ReturnUser(tmp);
			tmp = strtok(cmdtext, idx);
			if(PlayerInfo[playerid][pAdmin] >= 1)
			{
			    if(IsPlayerConnected(giveplayerid))
			    {
			        if(giveplayerid != INVALID_PLAYER_ID)
			        {
				        GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
						GetPlayerName(playerid, sendername, sizeof(sendername));
						new length = strlen(cmdtext);
						while ((idx < length) && (cmdtext[idx] <= ' '))
						{
							idx++;
						}
						new offset = idx;
						new result[64];
						while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
						{
							result[idx - offset] = cmdtext[idx];
							idx++;
						}
						result[idx - offset] = EOS;
						if(!strlen(result))
						{
							SendClientMessage(playerid, COLOR_WHITE, "USAGE: /unjail [playerid/PartOfName]");
							return 1;
						}
						SetPlayerInterior(giveplayerid, 0);
						SetPlayerVirtualWorld(playerid, 0);
						PlayerInfo[giveplayerid][pVirtualWorld] = 0;
						SetPlayerPos(giveplayerid, 533.8759,-1675.7471,18.7500,353.4335);
						SetPlayerFacingAngle(giveplayerid, 90);
						format(string,sizeof(string),"Admin %s has unjailed you.", RemoveUnderScore(playerid));
						SendClientMessage(playerid, COLOR_BLUE, string);
						KillTimer(unajailtimer);
					}
				}
			}
			else
			{
				SendClientMessage(playerid, COLOR_GRAD1, "   You are not authorized to use that command !");
			}
		}
		return 1;
	}
Reply
#2

can you not change if(!strlen(tmp)) to if(IsNull(cmdtxt)) ?
Reply
#3

Nope, didn't work.
Reply
#4

pawn Код:
if(strcmp(cmd, "/unjail", true) == 0)
{
    if(PlayerInfo[playerid][pAdmin] < 1)
    {
        SendClientMessage(playerid, COLOR_GRAD1, "   You are not authorized to use that command !");
        return 1;
    }
    tmp = strtok(cmdtext, idx);
    if(!strlen(tmp))
    {
        SendClientMessage(playerid, COLOR_WHITE, "USAGE: /unjail [playerid/PartOfName]");
        return 1;
    }
    new giveplayerid = ReturnUser(tmp);
    if(giveplayerid == INVALID_PLAYER_ID)
    {
        SendClientMessage(playerid, COLOR_WHITE, "   Player not found !");
        return 1;
    }
    KillTimer(unajailtimer); // should be unajailtimer[giveplayerid] and on top - new unajailtimer[MAX_PLAYERS];
    GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
    GetPlayerName(playerid, sendername, sizeof(sendername));
    SetPlayerInterior(giveplayerid, 0);
    SetPlayerVirtualWorld(playerid, 0);
    PlayerInfo[giveplayerid][pVirtualWorld] = 0;
    SetPlayerPos(giveplayerid, 533.8759,-1675.7471,18.7500,353.4335);
    SetPlayerFacingAngle(giveplayerid, 90);
    format(string,sizeof(string),"Admin %s has unjailed you.", RemoveUnderScore(playerid));
    SendClientMessage(giveplayerid, COLOR_BLUE, string);
    return 1;
}
Reply
#5

try this

pawn Код:
if(strcmp(cmd, "/unjail", true) == 0)
{
    if(PlayerInfo[playerid][pAdmin] < 1)
    {
        SendClientMessage(playerid, COLOR_GRAD1, "   You are not authorized to use that command !");
        return 1;
    }
    tmp = strtok(cmdtext, idx);
    if(!strlen(tmp))
    {
        SendClientMessage(playerid, COLOR_WHITE, "USAGE: /unjail [playerid/PartOfName]");
        return 1;
    }
    new giveplayerid = ReturnUser(tmp);
    if(giveplayerid == INVALID_PLAYER_ID)
    {
        SendClientMessage(playerid, COLOR_WHITE, "   Player not found !");
        return 1;
    }
    KillTimer(unajailtimer);
    GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
    GetPlayerName(playerid, sendername, sizeof(sendername));
    SetPlayerInterior(giveplayerid, 0);
    SetPlayerVirtualWorld(playerid, 0);
    PlayerInfo[giveplayerid][pVirtualWorld] = 0;
    SetPlayerPos(giveplayerid, 533.8759,-1675.7471,18.7500,353.4335);
    SetPlayerFacingAngle(giveplayerid, 90);
    format(string,sizeof(string),"Admin %s has unjailed you.", RemoveUnderScore(playerid));
    SendClientMessage(giveplayerid, COLOR_BLUE, string);
    return 1;
}
thank you
Reply
#6

Thanks, worked! Another question, added that if you are not ajailed you cannot unjail someone, but now even when someone is actually ajailed it also won't work..

Код:
if(strcmp(cmd, "/unjail", true) == 0)
{
    if(PlayerInfo[playerid][pAdmin] < 1)
    {
        SendClientMessage(playerid, COLOR_GRAD1, "You are not authorized to use that command.");
        return 1;
    }
    if(PlayerInfo[playerid][pAjailed] == 0)
    {
        SendClientMessage(playerid, COLOR_GREY, "This player is not admin jailed.");
        return 1;
    }
    tmp = strtok(cmdtext, idx);
    if(!strlen(tmp))
    {
        SendClientMessage(playerid, COLOR_WHITE, "USAGE: /unjail [playerid/PartOfName]");
        return 1;
    }
    new giveplayerid = ReturnUser(tmp);
    if(giveplayerid == INVALID_PLAYER_ID)
    {
        SendClientMessage(playerid, COLOR_WHITE, "   Player not found !");
        return 1;
    }
    KillTimer(unajailtimer); // should be unajailtimer[giveplayerid] and on top - new unajailtimer[MAX_PLAYERS];
    GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
    GetPlayerName(playerid, sendername, sizeof(sendername));
    SetPlayerInterior(giveplayerid, 0);
    SetPlayerVirtualWorld(playerid, 0);
    PlayerInfo[giveplayerid][pVirtualWorld] = 0;
    SetPlayerPos(giveplayerid, 533.8759,-1675.7471,18.7500,353.4335);
    SetPlayerFacingAngle(giveplayerid, 90);
    format(string,sizeof(string),"Admin %s has released you from admin jail.", RemoveUnderScore(playerid));
    SendClientMessage(giveplayerid, COLOR_BLUE, string);
    PlayerInfo[giveplayerid][pPrisons] -= 1;
    return 1;
}
Reply
#7

I actually meant it works when someone is NOT jailed and when someone is, which it is supposed to only give the message when someone isn't :P.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)