SA-MP Forums Archive
/skiptut doesn't work - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: /skiptut doesn't work (/showthread.php?tid=546169)



/skiptut doesn't work - AdzeeH - 13.11.2014

Hey, on my server /skiptut doesn't work and I don't know why it doesnt.

Here is the code:

Код:
CMD:skiptut(playerid, params[])
{
	if(PlayerInfo[playerid][pAdmin] < 4)
	{
 		SendClientMessage(playerid, COLOR_GRAD1, "You're not authorized to use that command!");
   		return 1;
 	}
	if(AdminDuty[playerid] != 1 && PlayerInfo[playerid][pAdmin] < 6)
 	{
  		SendClientMessage(playerid,COLOR_WHITE, "You're not on-duty as admin. To access your admin commands you must be on-duty. Type /aduty to go on-duty.");
		return 1;
	}
	new giveplayerid;
	if(sscanf(params, "u", giveplayerid))
		return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /skiptut [playerid/partofname]");
	if(PlayerInfo[giveplayerid][pTut]) return SendClientMessage(playerid, COLOR_GREY, "Player is not in the tutorial.");
	if(IsPlayerConnected(giveplayerid))
	{
	  Tut[giveplayerid] = SetTimerEx("TutFinal", 200, false, "i", giveplayerid);
	  KillTimer(Tut[giveplayerid]);
	}
	return 1;
}



Re: /skiptut doesn't work - OG Killo - 13.11.2014

Код:
CMD:skiptut(playerid, params[])
{
	if(PlayerInfo[playerid][pAdmin] < 4)
	{
 		SendClientMessage(playerid, COLOR_GRAD1, "You're not authorized to use that command!");
 	}
	if(AdminDuty[playerid] != 1 && PlayerInfo[playerid][pAdmin] < 6)
 	{
  		SendClientMessage(playerid,COLOR_WHITE, "You're not on-duty as admin. To access your admin commands you must be on-duty. Type /aduty to go on-duty.");
	}
	new giveplayerid;
	if(sscanf(params, "u", giveplayerid))
		return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /skiptut [playerid/partofname]");
	if(PlayerInfo[giveplayerid][pTut]) return SendClientMessage(playerid, COLOR_GREY, "Player is not in the tutorial.");
	if(IsPlayerConnected(giveplayerid))
	{
	  Tut[giveplayerid] = SetTimerEx("TutFinal", 200, false, "i", giveplayerid);
	  KillTimer(Tut[giveplayerid]);
	}
	return 1;
}
Don't really know if it'll work, I gave it a try.


Re: /skiptut doesn't work - Kwarde - 13.11.2014

OG Killo, don't forget the returns in the first two if statements.

Let's say you are admin level 2; you'll get the message that you're not admin level 4! But since no returned is used, if will keep going with the code and you will be avaible to use the command!

@AdzeeH: It is not working because you kill the timer that calls "TutFinal()"! And because it's killed it won't call the TutFinal() callback. Try to comment or remove that line, and then test again. Let me know if it worked or not. There's nothing wrong with your code except the KillTimer part!