Problem with variables in switch/case
#1

Hello! I have some problems with my scripts. Problems with variables and strings in callback OnDialogResponse. In top of callback I put this:
Код:
switch(dialogid)
{
And I closed with bracket } in bottom of this callback. I put these codes:

Код:
	case 367:
	{
	if(response)
	{
   		new sms[50],ZaidejoVardas[24];
   		if(sscanf(inputtext, "s[24]s[50]",ZaidejoVardas,sms)) return SendClientMessage(playerid, 0xFF0000AA, "Insert name and reason");
   		new Teis = StrFind(ZaidejoVardas);//StrFind is my own function. It finds player.
   		if(Teis == INVALID_PLAYER_ID) return SendClientMessage(playerid, 0xFF0000AA, "We can't find this player..");
   		if(IsPlayerNPC(Teis)) return SendClientMessage(playerid, 0xFF0000AA, "We can't find this player.");
                new zigas[250];
                format(zigas,sizeof(zigas),"Player name is %s, reason: %s",GetName(Teis),sms)//GetName is my own function. It returns player name.
	        SendClientMessage(playerid,-1,zigas);
	}
	}

	case 368:
	{
	if(response)
	{
   		new sms[50],ZaidejoVardas[24], laiks;
   		if(sscanf(inputtext, "s[24]ds[50]",ZaidejoVardas,laiks,sms)) return SendClientMessage(playerid, 0xFF0000AA, "Insert name, time(seconds) and reason");
   		new Teis = StrFind(ZaidejoVardas);//StrFind is my own function. It finds player.
   		if(Teis == INVALID_PLAYER_ID) return SendClientMessage(playerid, 0xFF0000AA, "We can't find this player..");
   		if(IsPlayerNPC(Teis)) return SendClientMessage(playerid, 0xFF0000AA, "We can't find this player.");
                new zigas[250];
                format(zigas,sizeof(zigas),"You muted %s, for %d seconds, reason: %s",GetName(Teis),laiks,sms)//GetName is my own function. It returns player name.
		SendClientMessage(playerid,-1,zigas);
	}
	}
And I have errors:

Код:
error 021: symbol already defined: "sms"
error 021: symbol already defined: "Teis"
If I do like this:


Код:
	case 367:
	{
	if(response)
	{
   		new sms[50],ZaidejoVardas[24];
   		if(sscanf(inputtext, "s[24]s[50]",ZaidejoVardas,sms)) return SendClientMessage(playerid, 0xFF0000AA, "Insert name and reason");
   		new Teis = StrFind(ZaidejoVardas);//StrFind is my own function. It finds player.
   		if(Teis == INVALID_PLAYER_ID) return SendClientMessage(playerid, 0xFF0000AA, "We can't find this player..");
   		if(IsPlayerNPC(Teis)) return SendClientMessage(playerid, 0xFF0000AA, "We can't find this player.");
                new zigas[250];
                format(zigas,sizeof(zigas),"Player name is %s, reason: %s",GetName(Teis),sms)//GetName is my own function. It returns player name.
	        SendClientMessage(playerid,-1,zigas);
	}
	}

	/*case 368:
	{
	if(response)
	{
   		new sms[50],ZaidejoVardas[24], laiks;
   		if(sscanf(inputtext, "s[24]ds[50]",ZaidejoVardas,laiks,sms)) return SendClientMessage(playerid, 0xFF0000AA, "Insert name, time(seconds) and reason");
   		new Teis = StrFind(ZaidejoVardas);//StrFind is my own function. It finds player.
   		if(Teis == INVALID_PLAYER_ID) return SendClientMessage(playerid, 0xFF0000AA, "We can't find this player..");
   		if(IsPlayerNPC(Teis)) return SendClientMessage(playerid, 0xFF0000AA, "We can't find this player.");
                new zigas[250];
                format(zigas,sizeof(zigas),"You muted %s, for %d seconds, reason: %s",GetName(Teis),laiks,sms)//GetName is my own function. It returns player name.
		SendClientMessage(playerid,-1,zigas);
	}
	}*/
Everything works right. What I need to do? I can't do anything Please help if u can I will be very grateful.
Reply


Messages In This Thread
Problem with variables in switch/case - by Vvolk - 05.07.2012, 19:56
Re: Problem with variables in switch/case - by Steven82 - 05.07.2012, 19:59
Re: Problem with variables in switch/case - by Vvolk - 05.07.2012, 20:00
Re: Problem with variables in switch/case - by Steven82 - 05.07.2012, 20:07
Re: Problem with variables in switch/case - by Vvolk - 05.07.2012, 20:11

Forum Jump:


Users browsing this thread: 1 Guest(s)