Annoying /jail problem
#1

Hey guys
so I got this command
Код:
    if(strcmp(cmd,"/jail",true) == 0)
    {
  		if(PlayerInfo[playerid][pAdminLevel] < 1)
		{
            SendClientMessage(playerid,COLOR_AFOR,"You are not authorized to use this command");
		}
  			if(PlayerInfo[playerid][pAdminLevel] > 0)
			{
			new tmp[256],tmp2[256],victim,admin[MAX_PLAYER_NAME],victimname[MAX_PLAYER_NAME],string[256];
			tmp = strtok(cmdtext, idx);
			tmp2 = strtok(cmdtext, idx);
			if(strlen(tmp) == 0) return SendClientMessage(playerid,COLOR_RED,"Usage : /jail [PLAYERID][TIME]");
			if(strlen(tmp2) == 0) return SendClientMessage(playerid,COLOR_RED,"Usage : /jail [PLAYERID][TIME]");
			victim = strval(tmp);
			SetTimerEx("AdminJail", strval(tmp2), false, "i", playerid);
			GetPlayerName(playerid,admin,sizeof(admin));
			format(string,sizeof(string),"You have been jailed for %i by admin %s.",strval(tmp2),admin);
			SendClientMessage(victim,COLOR_ADMINS,string);
			GetPlayerName(victim,victimname,sizeof(victimname));
			format(string,sizeof(string),"You have put %s in jail for %i.",victimname,strval(tmp2));
			SendClientMessage(playerid,COLOR_ADMINS,string);
			new RandomPos = random(3);
			switch(RandomPos)
			{
			    case 0:
			    {
			    SetPlayerPos(victim,262.9509,77.4370,1001.0391);
			    SetPlayerInterior(playerid,6);
			    }
			    case 1:
			    {
			    SetPlayerPos(victim,264.1004,76.5202,1001.0391);
			    SetPlayerInterior(playerid,6);
      			}
			    case 2:
			    {
			    SetPlayerPos(victim,264.9439,78.4224,1001.0391);
			    SetPlayerInterior(playerid,6);
			    }
			}
		}
		return 1;
	}
and up at the GM
Код:
forward AdminJail(playerid);
and up at the GM
Код:
public AdminJail(playerid)
{
	SetPlayerPos(playerid,1555.2797851563,-1675.5520019531,16.716053009033);
	SetPlayerInterior(playerid,0);
	SendClientMessage(playerid,COLOR_AFOR,"You have been released from the jail!");
}
AND NOTHING IS ******* working
Reply
#2

pawn Код:
public AdminJail(playerid)
{
    SetPlayerPos(playerid,1555.2797851563,-1675.5520019531,16.716053009033);
    SetPlayerInterior(playerid,0);
    SendClientMessage(playerid,COLOR_AFOR,"You have been released from the jail!");
    return 1;
}
Reply
#3

Also, check this line:
Quote:

SetTimerEx("AdminJail", strval(tmp2), false, "i", playerid);

First of all it will set the timer on the person who typed /jail, so change playerid to victim.

Also, sometimes for an unknown reason(in my case) strval(..) in a function doesn't work properly.

So, try this:

pawn Код:
new victimtime = strval(tmp2);
SetTimerEx("AdminJail", victimtime, false, "i", victim);
And to be honest, I'm quite used to SSCANF, so I'm not sure, but I don't think it's necessarily to use strval in this case, so you could try this if the code above doesn't work:

pawn Код:
SetTimerEx("AdminJail", tmp2, false, "i", victim);
Somehow I have the feeling I'm wrong.. But yeah.

Golden tip: Use SSCANF, it will solve all your problems.
Reply
#4

Quote:
Originally Posted by Biesmen
Посмотреть сообщение
Golden tip: Use SSCANF, it will solve all your problems.
What he said.
Reply
#5

okey thank you guys . not I got 2 more things...
first off all , amm .... how do I make the time in seconds ? so I wont have to write 5000 if I want to jail someone for 5000 seconds.....

Next is how do I save the jailtime in dini
Reply
#6

Time in seconds:
pawn Код:
SetTimerEx("AdminJail", victimtime * 1000, false, "i", victim);
Why * 1000?
1 second = 1000 milliseconds.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)