Offline Jail
#1

Well, haven't been needing to ask for help for a while, but yeah, this command really got to me, it's saying "giveplayer" isn't defined, when i'm sure as hell i defined it, so i have no idea what i'm doing wrong here

Код:
CMD:ojail(playerid, params[])
{
	if(PlayerInfo[playerid][pAdmin] >= 2)
	{
	    new playa,time,reason[65];
	    if(!sscanf(params, "uis[64]", playa, time, reason))
	    {
	        new pID = MySQLCheckAccount(giveplayer);
			new giveplayer[MAX_PLAYER_NAME];
			giveplayer = PlayerNameEx(playa);
			new sendername[MAX_PLAYER_NAME];
			sendername = PlayerNameEx(playerid);
			new string[128];
			format(string, sizeof(string), "* You jailed %s for %d minute(s).", giveplayer, time);
			SendClientMessage(playerid, COLOR_LIGHTRED, string);
			format(string, sizeof(string), "System: %s was offline jailed by %s for %d minute(s), Rason: %s", giveplayer, sendername, time, reason);
			BroadCast(COLOR_LIGHTRED, string);
			format(string, sizeof(string), "UPDATE `userinfo` SET `Jailed` = 1 WHERE `Jailed` = 500 WHERE `ID`= %d;", pID);
			mysql_query(string);
			return 1;
		}
	}
	else
	{
	    SendClientMessage(playerid, COLOR_LIGHTRED, "You are not authorized to use this command!");
	    return 1;
	}
	return 1;
}
Reply
#2

new pID = MySQLCheckAccount(giveplayer);
You are using the variable before you initialized it.
Reply
#3

May I remind you that sscanf's 'u' specifier only works for online players? It's not a universal search-all-accounts tool.
Reply
#4

use my code, this works as long as your server uses [zcmd]

Код:
CMD:ojail(playerid, params[])
{
	if(PlayerInfo[playerid][pAdmin] >= 3)
	{
		new string[128], name[MAX_PLAYER_NAME], minutes, reason[64];
		if(sscanf(params, "s[24]ds[64]", name, minutes, reason)) return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /prisonaccount [playername] [time (minutes)] [reason]");

        new giveplayerid = ReturnUser(name);
        if(IsPlayerConnected(giveplayerid))
		{
			if(PlayerInfo[giveplayerid][pAdmin] >= PlayerInfo[playerid][pAdmin])
			{
				SendClientMessageEx(playerid, COLOR_WHITE, "You can't perform this action on an equal or higher level administrator.");
				return 1;
			}
			SetPlayerArmedWeapon(giveplayerid, 0);

			if(GetPVarInt(giveplayerid, "IsInArena") >= 0)
			{
				LeavePaintballArena(giveplayerid, GetPVarInt(giveplayerid, "IsInArena"));
			}

			GameTextForPlayer(giveplayerid, "~w~Welcome to ~n~~r~You Fucked Up Land", 5000, 3);
			new year, month,day;
			ResetPlayerWeaponsEx(giveplayerid);
			getdate(year, month, day);
			format(string, sizeof(string), "AdmCmd: %s has been prisoned by %s, reason: %s(%d-%d-%d)", GetPlayerNameEx(giveplayerid), GetPlayerNameEx(playerid), reason, month, day, year);
			Log("logs/admin.log", string);
			SendClientMessage(playerid, COLOR_WHITE, "The player is online and has been prisoned!");
			format(string, sizeof(string), "AdmCmd: %s has been prisoned by %s, reason: %s", GetPlayerNameEx(giveplayerid), GetPlayerNameEx(playerid), reason);
			SendClientMessageToAllEx(COLOR_LIGHTRED, string);
			WantedPoints[giveplayerid] = 0;
			PlayerInfo[giveplayerid][pWantedLevel] = 0;
			SetPlayerWantedLevel(giveplayerid, 0);
			PlayerInfo[giveplayerid][pJailed] = 4;
			PlayerInfo[giveplayerid][pJailTime] = minutes*60;
			format(PlayerInfo[giveplayerid][pPrisonReason], 128, "[OOC][PRISON] %s", reason);
			format(PlayerInfo[giveplayerid][pPrisonedBy], MAX_PLAYER_NAME, "%s", GetPlayerNameEx(playerid));
			PhoneOnline[giveplayerid] = 1;
			TogglePlayerControllable(giveplayerid, 0);
			GameTextForPlayer(giveplayerid, "Objects loading...", 4000, 5);
			SetPVarInt(giveplayerid, "LoadingObjects", 1);
			SetTimerEx("SafeLoadObjects", 4000, 0, "d", giveplayerid);
			SetPlayerInterior(giveplayerid, 1);
			PlayerInfo[giveplayerid][pInt] = 1;
			new rand = random(sizeof(OOCPrisonSpawns));
			Streamer_UpdateEx(giveplayerid, OOCPrisonSpawns[rand][0], OOCPrisonSpawns[rand][1], OOCPrisonSpawns[rand][2]);
			SetPlayerPos(giveplayerid, OOCPrisonSpawns[rand][0], OOCPrisonSpawns[rand][1], OOCPrisonSpawns[rand][2]);
			SetPlayerSkin(giveplayerid, 50);
			SetPlayerColor(giveplayerid, TEAM_APRISON_COLOR);
		}
		else if(doesAccountExist(name))
		{
			OnPlayerOfflineLogin(name);
			if( PlayerInfo[MAX_PLAYERS][pPermaBanned] == 3 || PlayerInfo[MAX_PLAYERS][pBanned] >= 1 )
			{
				SendClientMessageEx( playerid, COLOR_WHITE, "That player is banned." );
				return 1;
			}
			else
			{
				PlayerInfo[MAX_PLAYERS][pJailTime] = minutes*60;
				PlayerInfo[MAX_PLAYERS][pJailed] = 4;
				format(PlayerInfo[MAX_PLAYERS][pPrisonReason], 64, "[OOC][PRISONACC] %s", reason);
				format(PlayerInfo[MAX_PLAYERS][pPrisonedBy], 24, "%s", GetPlayerNameEx(playerid));
				OnPlayerOfflineSave(name);
				new year, month,day;
				getdate(year, month, day);
				format(string, sizeof(string), "AdmCmd: %s was offline prisoned by %s, reason: %s (%d-%d-%d)", name, GetPlayerNameEx(playerid), reason, month,day,year);
				Log("logs/admin.log", string);
				format(string, 128, "AdmCmd: %s was offline prisoned by %s, reason: %s", name, GetPlayerNameEx(playerid), reason);
				ABroadCast(COLOR_LIGHTRED,string,2);
			}
		}
		else
		{
			SendClientMessageEx( playerid, COLOR_WHITE, "That account doesn't exist." );
		}
	}
	return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)