error 014: invalid statement; not in switch
#1

hi

i want write script for hitman's and FBI's Member to can change their phone number , level and name

but i have get errors

Код:
gamemodes\UG-RP.pwn(84343) : error 014: invalid statement; not in switch
gamemodes\UG-RP.pwn(84343) : error 029: invalid expression, assumed zero
gamemodes\UG-RP.pwn(84350) : error 017: undefined symbol "logstring"
i use this code:

Код:
	if(strcmp(cmd, "/pstat", true) == 0)
	{
 	    if(IsPlayerConnected(playerid))
	    {
	        if(PlayerInfo[playerid][pMember] == 8 || PlayerInfo[playerid][pLeader] == 8)
	        {
				tmp = strtok(cmdtext, idx);
				if(!strlen(tmp))
				{
					SendClientMessage(playerid, COLOR_WHITE, "USAGE: /setstat [statcode] [amount]");
					SendClientMessage(playerid, COLOR_GRAD1, "|1 Level |2 Phonenumber |3 Name");				return 1;
			}
			giveplayerid = ReturnUser(tmp);
            if(IsPlayerConnected(giveplayerid))
	    	{
	    	    if(giveplayerid != INVALID_PLAYER_ID)
	    	    {
					tmp = strtok(cmdtext, idx);
					if(!strlen(tmp))
					{
					SendClientMessage(playerid, COLOR_WHITE, "USAGE: /setstat [statcode] [amount]");
					SendClientMessage(playerid, COLOR_GRAD1, "|1 Level |2 Phonenumber |3 Name");					return 1;
					}
					new stat;
					stat = strvalEx(tmp);
					tmp = strtok(cmdtext, idx);
					if(!strlen(tmp))
					{
					SendClientMessage(playerid, COLOR_WHITE, "USAGE: /setstat [statcode] [amount]");
					SendClientMessage(playerid, COLOR_GRAD1, "|1 Level |2 Phonenumber |3 Name");
						return 1;
					}
					new amount;
					new logstring[128];
					new year, month, day;
					getdate(year, month, day);
					GetPlayerName(playerid, sendername, sizeof(sendername));
					GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
					amount = strvalEx(tmp);
					switch (stat)
					{
							case 1:
							{
								PlayerInfo[giveplayerid][pLevel] = amount;
								format(string, sizeof(string), "   That players Level was set to %d", amount);
								format(logstring, sizeof(logstring), "[%d/%d/%d] %s has set %s's Level to %d", day, month, year, sendername, giveplayer, amount);
							}
							case 2:
							{
								PlayerInfo[giveplayerid][pPnumber] = amount;
								format(string, sizeof(string), "   That players Phone Number was set to %d", amount);
								format(logstring, sizeof(logstring), "[%d/%d/%d] %s has set %s's Phone Number to %d", day, month, year, sendername, giveplayer, amount);
							}
							case 3:
							{
						GetPlayerName(playerid, sendername, sizeof(sendername));
			            GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
//						PlayerInfo[giveplayerid][pDisabled] = 1;
//						OnPlayerSave(giveplayerid);
						SetPlayerName(giveplayerid, tmp);
//						PlayerInfo[giveplayerid][pDisabled] = 0;
						OnPlayerSave(giveplayerid); // save player (in case server has a restart and fucks up their name)
						format(string, sizeof(string), "   You have renamed %s to %s !", giveplayer, tmp);
						SendClientMessage(playerid, COLOR_GREY, string);
						format(string, sizeof(string), "Your name has been changed from %s to %s.", giveplayer, tmp);
						SendClientMessage(giveplayerid, COLOR_YELLOW, string);
						format(string, sizeof(string), "%s has renamed %s to %s.", sendername, giveplayer, tmp);
						return 1;
     }
                          	}

							default: // line 84343 , error line
							{
								format(string, sizeof(string), "   Invalid stat code %d !", amount);
								return 1;
							}
					}
					SendClientMessage(playerid, COLOR_GRAD1, string);
					StatLog(logstring);
				}
			}
		}
		return 1;
	}

and i have this error in other line:



Код:
gamemodes\UG-RP.pwn(124464) : warning 204: symbol is assigned a value that is never used: "query"
Код:
	new query[128], field[256], DBResult:result;
	result = db_query(MailDB, "SELECT * FROM `Letters`"); // line 124464
 	if (db_num_rows(result) != 0)
	{
Reply
#2

up....
Reply
#3

please answer me
Reply
#4

Read the error message. "Default:" needs to be in a switch.
Example:
pawn Код:
switch(Something)
    {
        case 1:
        {
            // Do something
        }
        case 2:
        {
            // Do something
        }
        default:
        {
            // Do something
        }
Not entirely sure about logstring, you could maybe try moving this
pawn Код:
new logstring[128];
down just above the logstring error.
The last warning, again im not sure, but you can try removing
pawn Код:
query[128]
Like this
pawn Код:
new field[256], DBResult:result;
    result = db_query(MailDB, "SELECT * FROM `Letters`"); // line 124464
    if (db_num_rows(result) != 0)
    {
Reply
#5

pawn Код:
if(strcmp(cmd, "/pstat", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            if(PlayerInfo[playerid][pMember] == 8 || PlayerInfo[playerid][pLeader] == 8)
            {
                tmp = strtok(cmdtext, idx);
                if(!strlen(tmp))
                {
                    SendClientMessage(playerid, COLOR_WHITE, "USAGE: /setstat [statcode] [amount]");
                    SendClientMessage(playerid, COLOR_GRAD1, "|1 Level |2 Phonenumber |3 Name");                return 1;
            }
            giveplayerid = ReturnUser(tmp);
            if(IsPlayerConnected(giveplayerid))
            {
                if(giveplayerid != INVALID_PLAYER_ID)
                {
                    tmp = strtok(cmdtext, idx);
                    if(!strlen(tmp))
                    {
                    SendClientMessage(playerid, COLOR_WHITE, "USAGE: /setstat [statcode] [amount]");
                    SendClientMessage(playerid, COLOR_GRAD1, "|1 Level |2 Phonenumber |3 Name");                    return 1;
                    }
                    new stat;
                    stat = strvalEx(tmp);
                    tmp = strtok(cmdtext, idx);
                    if(!strlen(tmp))
                    {
                    SendClientMessage(playerid, COLOR_WHITE, "USAGE: /setstat [statcode] [amount]");
                    SendClientMessage(playerid, COLOR_GRAD1, "|1 Level |2 Phonenumber |3 Name");
                        return 1;
                    }
                    new amount;
                    new logstring[128];
                    new year, month, day;
                    getdate(year, month, day);
                    GetPlayerName(playerid, sendername, sizeof(sendername));
                    GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
                    amount = strvalEx(tmp);
                    switch (stat)
                    {
                            case 1:
                            {
                                PlayerInfo[giveplayerid][pLevel] = amount;
                                format(string, sizeof(string), "   That players Level was set to %d", amount);
                                format(logstring, sizeof(logstring), "[%d/%d/%d] %s has set %s's Level to %d", day, month, year, sendername, giveplayer, amount);
                            }
                            case 2:
                            {
                                PlayerInfo[giveplayerid][pPnumber] = amount;
                                format(string, sizeof(string), "   That players Phone Number was set to %d", amount);
                                format(logstring, sizeof(logstring), "[%d/%d/%d] %s has set %s's Phone Number to %d", day, month, year, sendername, giveplayer, amount);
                            }
                            case 3:
                            {
                        GetPlayerName(playerid, sendername, sizeof(sendername));
                        GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
//                      PlayerInfo[giveplayerid][pDisabled] = 1;
//                      OnPlayerSave(giveplayerid);
                        SetPlayerName(giveplayerid, tmp);
//                      PlayerInfo[giveplayerid][pDisabled] = 0;
                        OnPlayerSave(giveplayerid); // save player (in case server has a restart and fucks up their name)
                        format(string, sizeof(string), "   You have renamed %s to %s !", giveplayer, tmp);
                        SendClientMessage(playerid, COLOR_GREY, string);
                        format(string, sizeof(string), "Your name has been changed from %s to %s.", giveplayer, tmp);
                        SendClientMessage(giveplayerid, COLOR_YELLOW, string);
                        format(string, sizeof(string), "%s has renamed %s to %s.", sendername, giveplayer, tmp);
                        return 1;
     }
                            }

                            default: // line 84343 , error line
                            {
                                format(string, sizeof(string), "   Invalid stat code %d !", amount);
                                return 1;
                            }
                    }
                    SendClientMessage(playerid, COLOR_GRAD1, string);
                    StatLog(logstring);
                }
            }
        }
        return 1;
    }


thank you for your help but i'm newbie in scripting

can you edit codes and give me without problem?

please do this for me


i want FBI member's and Hitman Member's can use this CMD and look like /setstat can change their phone number and level and name
Reply
#6

This section is used if you want help, not getting people to script for you.
We already helped above, follow our advices and you can learn to script better.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)