SA-MP Forums Archive
Need help with command! - 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: Need help with command! (/showthread.php?tid=574866)



Need help with command! - baba1234 - 21.05.2015

Greetings, I have made command transfer money and when someone uses /transfer he get dialogs thats all good but if the player types card number of a player and if that card number isnt right he will get message player not connected etc.. and if he tries to again use command /transfer dialog wont show.

Here is the code


Код:
if(!strcmp(cmdtext, "/posaljinovac"))
	 {
	    if(PlayerInfo[playerid][CardOwner]==0) return SendClientMessage(playerid,COLOR_RED,"Nemas bankovni racun,mozes ga otvoriti u banci za 500$!");
	    else if(IsPlayerInRangeOfPoint(playerid, 3.0, 1401.0518,1319.4008,1501.0859))
	    {
	    	if(PlayerInfo[playerid][CardOwner]==1)
			{
		   		if(tShow[playerid]==0)
		   		{
			 		tShow[playerid]=1;
		     		ShowPlayerDialog(playerid,DIALOG_CARDCHECK,DIALOG_STYLE_INPUT,""COL_SPLAVA"Cloud-Banka:"COL_BIJELA"Transfer","Upisite kod kartice igraca:","OK","Cancel");
		   		}
			}else
			    {
			    	SendClientMessage(playerid, COLOR_GREY, "Moras biti u banci!");
		    	}
		}
  		return 1;
	}


OnDialogRespons

new transferplayer;//this will store the playerid's wich has the inserted card number
  	if(dialogid==12)
  {
	if(response==0) return SendClientMessage(playerid,COLOR_RED,"Prijenos prekinut!");
	if(response==1)
	{
	  if(!strval(inputtext)) return SendClientMessage(playerid,COLOR_RED,"Krivi broj racuna!");//again,he can only insert a numeric value in order to avoid bugs/errors
	  else
	  {
		 new cardnum;
		 cardnum=strval(inputtext);
		 new OK=0;//this variable will tell us if there's any player with the inserted card number(1 YES,0 NO)
		 for(new i=0;i<MAX_PLAYERS;i++)//we start the loop
		 {
			 if(BankInfo[i][CardNumber]==cardnum)//we check the players cardnumber,if it's the same as the inserted one
			 {
				transferplayer=i;//if yes,we store his ID,into the variable defined earlier
				OK=1;//we make the OK variable 1(THERE IS SOMEONE with the inserted card)
				break;//we stoop the loop
			 }
		 }
		 if(OK==0) SendClientMessage(playerid,COLOR_RED,"Korisnik nije konektiran ili je broj racuna krivi!");
		 else
		 {
			 ShowPlayerDialog(playerid,DIALOG_TRANSFERM, DIALOG_STYLE_INPUT, ""COL_SPLAVA"Cloud-Banka:"COL_BIJELA"Transfer", "Upisite sumu novca za "COL_SPLAVA"prebacivanje", "Prebaci", "Odustani");//we show the ACTUAL TRANSFER dialog
		 }
	  }
    }
  }



Re: Need help with command! - baba1234 - 21.05.2015

cmon anyone? BUMP


Re: Need help with command! - rappy93 - 21.05.2015

Try resetting these after the command has been executed:

tShow[playerid]=1;

and

OK=0;

If these are not reset after you type the command, the second time the script will bug out and behave in a way that you don't want it to.