Problem with variables in switch/case -
Vvolk - 05.07.2012
Hello! I have some problems with my scripts. Problems with variables and strings in callback OnDialogResponse. In top of callback I put this:
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.
Re: Problem with variables in switch/case -
Steven82 - 05.07.2012
Are there any dialogs above that using the same variables as "sms" and "teis"? Or any dialogs in general?
Re: Problem with variables in switch/case -
Vvolk - 05.07.2012
No. Variables only here, but above are more dialogs.
Re: Problem with variables in switch/case -
Steven82 - 05.07.2012
Try this code.
pawn Код:
case 367:
{
if(response)
{
new sms[50],ZaidejoVardas[24], Teis = StrFind(ZaidejoVardas);
if(sscanf(inputtext, "s[24]s[50]",ZaidejoVardas,sms)) return SendClientMessage(playerid, 0xFF0000AA, "Insert name and reason");
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 ZaidejoVardas[24], laiks;
if(sscanf(inputtext, "s[24]ds[50]",ZaidejoVardas,laiks,sms)) return SendClientMessage(playerid, 0xFF0000AA, "Insert name, time(seconds) and reason");
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);
}
}
Re: Problem with variables in switch/case -
Vvolk - 05.07.2012
No, it won't work...