Jump to content

[REZOLVAT] Ajutor


Salon
 Share

Recommended Posts

Am incercat sa fac job miner si imi tot da erori de la "case"

 

Erorile: 


D:\newsman + roll ( jumate\gamemodes\wa-rpg.pwn(5066) : warning 217: loose indentation
D:\newsman + roll ( jumate\gamemodes\wa-rpg.pwn(5066) : error 014: invalid statement; not in switch
D:\newsman + roll ( jumate\gamemodes\wa-rpg.pwn(5066) : warning 215: expression has no effect
D:\newsman + roll ( jumate\gamemodes\wa-rpg.pwn(5066) : error 001: expected token: ";", but found ":"
D:\newsman + roll ( jumate\gamemodes\wa-rpg.pwn(5066) : error 029: invalid expression, assumed zero
D:\newsman + roll ( jumate\gamemodes\wa-rpg.pwn(5066) : fatal error 107: too many error messages on one line
 
Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
 
 
4 Errors.

Si codul:

	
	case 172:
		{
			DisablePlayerCheckpointEx(playerid);
			CP[playerid] ++;
			PlayerTextDrawSetString(playerid, InfosTD, "Du-te la ~r~~h~checkpoint-ul~w~~h~ de pe mapa pentru a duce minerul!");
			SetTimerEx("HideTextdraw", 5000, 0, "%d", playerid);
			PlayerTextDrawShow(playerid, InfosTD);		
			new rand = random(1);
			switch(rand) {
				case 0: SetPlayerCheckpointEx(playerid,-2079.0068,-884.1394,32.1719,2.0); // cp
				case 1: SetPlayerCheckpointEx(playerid,-2081.6643,-931.5534,32.1719,2.0); // cp
			}
		}

	case 173: {
			DisablePlayerCheckpointEx(playerid);
			CP[playerid] --;	
			PlayerTextDrawSetString(playerid, InfosTD, "Du-te la ~r~~h~checkpoint-ul~w~~h~ de pe mapa pentru a mina din nou minereurile!");
			SetTimerEx("HideTextdraw", 5000, 0, "%d", playerid);
			PlayerTextDrawShow(playerid, InfosTD);			
			new rand = random(2);
			DisablePlayerCheckpointEx(playerid);
			switch(rand) {
				case 0: {
					SetPlayerCheckpointEx(playerid, -1716.2394,-2134.1418,50.6371, 2.0);			
				}
				case 1: {
					SetPlayerCheckpointEx(playerid, -973.7756,-1484.9133,93.5230, 2.0);
				}
				case 2: {	
					SetPlayerCheckpointEx(playerid, -1785.0052,-1317.6433,33.2301, 2.0);
				}
			}
			PlayerInfo[playerid][pMinerSkill] ++;
			UpdateVar(playerid, "MinerSkill", PlayerInfo[playerid][pMinerSkill]);
			GiveJobSalary(playerid);
		}		
	}

Linia ce da erori e "case 172: {"...

Link to comment
Share on other sites

Incearca codul:

 

    case 172: {
        DisablePlayerCheckpointEx(playerid);
        CP[playerid] ++;
        PlayerTextDrawSetString(playerid, InfosTD, "Du-te la ~r~~h~checkpoint-ul~w~~h~ de pe mapa pentru a duce minerul!");
        SetTimerEx("HideTextdraw", 5000, 0, "%d", playerid);
        PlayerTextDrawShow(playerid, InfosTD);      
        new rand = random(1);
        switch(rand) {
            case 0: SetPlayerCheckpointEx(playerid,-2079.0068,-884.1394,32.1719,2.0); // cp
            case 1: SetPlayerCheckpointEx(playerid,-2081.6643,-931.5534,32.1719,2.0); // cp
        }
    }
    case 173: {
        DisablePlayerCheckpointEx(playerid);
        CP[playerid] --;    
        PlayerTextDrawSetString(playerid, InfosTD, "Du-te la ~r~~h~checkpoint-ul~w~~h~ de pe mapa pentru a mina din nou minereurile!");
        SetTimerEx("HideTextdraw", 5000, 0, "%d", playerid);
        PlayerTextDrawShow(playerid, InfosTD);          
        new rand = random(2);
        DisablePlayerCheckpointEx(playerid);
        switch(rand) {
            case 0: {
                SetPlayerCheckpointEx(playerid, -1716.2394,-2134.1418,50.6371, 2.0);            
            }
            case 1: {
                SetPlayerCheckpointEx(playerid, -973.7756,-1484.9133,93.5230, 2.0);
            }
            case 2: {   
                SetPlayerCheckpointEx(playerid, -1785.0052,-1317.6433,33.2301, 2.0);
            }
        }
        PlayerInfo[playerid][pMinerSkill] ++;
        UpdateVar(playerid, "MinerSkill", PlayerInfo[playerid][pMinerSkill]);
        GiveJobSalary(playerid);
    }
Link to comment
Share on other sites

Deoarece nu ai oferit mai mult cod, o sa presupun ca eroarea este din cauza ca ai creat acele case-uri fara un "switch" care sa le acopere..

 

Switch-case functioneaza altfel:

switch(variabila)
{
case 0: // daca variabila = 0
{
// cod
}
case 1: // daca variabila = 1
{
// cod
}
case 1337: // daca variabila = 1337
{
// cod 
}
// etc
}

Respecta si vei fi respectat.

 

BigInt Pawn:

Pacman C++: 

Snake C++:

Minesweeper C++:

 

mattbb.cash

leaks.ro

Link to comment
Share on other sites

Am incercat sa fac job miner si imi tot da erori de la "case"

 

Erorile: 


D:\newsman + roll ( jumate\gamemodes\wa-rpg.pwn(5066) : warning 217: loose indentation
D:\newsman + roll ( jumate\gamemodes\wa-rpg.pwn(5066) : error 014: invalid statement; not in switch
D:\newsman + roll ( jumate\gamemodes\wa-rpg.pwn(5066) : warning 215: expression has no effect
D:\newsman + roll ( jumate\gamemodes\wa-rpg.pwn(5066) : error 001: expected token: ";", but found ":"
D:\newsman + roll ( jumate\gamemodes\wa-rpg.pwn(5066) : error 029: invalid expression, assumed zero
D:\newsman + roll ( jumate\gamemodes\wa-rpg.pwn(5066) : fatal error 107: too many error messages on one line
 
Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
 
 
4 Errors.

Si codul:

	
	case 172:
		{
			DisablePlayerCheckpointEx(playerid);
			CP[playerid] ++;
			PlayerTextDrawSetString(playerid, InfosTD, "Du-te la ~r~~h~checkpoint-ul~w~~h~ de pe mapa pentru a duce minerul!");
			SetTimerEx("HideTextdraw", 5000, 0, "%d", playerid);
			PlayerTextDrawShow(playerid, InfosTD);		
			new rand = random(1);
			switch(rand) {
				case 0: SetPlayerCheckpointEx(playerid,-2079.0068,-884.1394,32.1719,2.0); // cp
				case 1: SetPlayerCheckpointEx(playerid,-2081.6643,-931.5534,32.1719,2.0); // cp
			}
		}

	case 173: {
			DisablePlayerCheckpointEx(playerid);
			CP[playerid] --;	
			PlayerTextDrawSetString(playerid, InfosTD, "Du-te la ~r~~h~checkpoint-ul~w~~h~ de pe mapa pentru a mina din nou minereurile!");
			SetTimerEx("HideTextdraw", 5000, 0, "%d", playerid);
			PlayerTextDrawShow(playerid, InfosTD);			
			new rand = random(2);
			DisablePlayerCheckpointEx(playerid);
			switch(rand) {
				case 0: {
					SetPlayerCheckpointEx(playerid, -1716.2394,-2134.1418,50.6371, 2.0);			
				}
				case 1: {
					SetPlayerCheckpointEx(playerid, -973.7756,-1484.9133,93.5230, 2.0);
				}
				case 2: {	
					SetPlayerCheckpointEx(playerid, -1785.0052,-1317.6433,33.2301, 2.0);
				}
			}
			PlayerInfo[playerid][pMinerSkill] ++;
			UpdateVar(playerid, "MinerSkill", PlayerInfo[playerid][pMinerSkill]);
			GiveJobSalary(playerid);
		}		
	}

Linia ce da erori e "case 172: {"...

Incearca acum, trebuie sa mearga:

case 172:
        {
            DisablePlayerCheckpointEx(playerid);
            CP[playerid] ++;
            PlayerTextDrawSetString(playerid, InfosTD, "Du-te la ~r~~h~checkpoint-ul~w~~h~ de pe mapa pentru a duce minerul!");
            SetTimerEx("HideTextdraw", 5000, 0, "%d", playerid);
            PlayerTextDrawShow(playerid, InfosTD);     
            new rand = random(2);
            switch(rand) {
                case 0: SetPlayerCheckpointEx(playerid,-2079.0068,-884.1394,32.1719,2.0); // cp
                case 1: SetPlayerCheckpointEx(playerid,-2081.6643,-931.5534,32.1719,2.0); // cp
            }
        }
 
    case 173: {
            DisablePlayerCheckpointEx(playerid);
            CP[playerid] --;   
            PlayerTextDrawSetString(playerid, InfosTD, "Du-te la ~r~~h~checkpoint-ul~w~~h~ de pe mapa pentru a mina din nou minereurile!");
            SetTimerEx("HideTextdraw", 5000, 0, "%d", playerid);
            PlayerTextDrawShow(playerid, InfosTD);         
            new rand = random(3);
            DisablePlayerCheckpointEx(playerid);
            switch(rand) {
                case 0: {
                    SetPlayerCheckpointEx(playerid, -1716.2394,-2134.1418,50.6371, 2.0);           
                }
                case 1: {
                    SetPlayerCheckpointEx(playerid, -973.7756,-1484.9133,93.5230, 2.0);
                }
                case 2: {  
                    SetPlayerCheckpointEx(playerid, -1785.0052,-1317.6433,33.2301, 2.0);
                }
            }
            PlayerInfo[playerid][pMinerSkill] ++;
            UpdateVar(playerid, "MinerSkill", PlayerInfo[playerid][pMinerSkill]);
            GiveJobSalary(playerid);
        }      
    }

La case 172: ai avut rand = random(1), si 2 variante, case 0 si case 1. Functia random e un numar aleatoriu incepand de la 0 pana la nr maxim(x-1), de exemplu tu ai pus random(1), adica functia il putea folosea doar pe case 0 nu si pe case 1 si de aceea ti-a dat eroare, e ca un string doar ca la string nu iti da eroare ci nu ti-l afiseaza pur si simplu in chat mesajul respectiv, cred ca intelegi la ce ma refer, e la fel si la case 173, ti-am modificat doar liniile new rand = random(x);

Edited by Ken
Link to comment
Share on other sites

Incearca acum, trebuie sa mearga:

case 172:
        {
            DisablePlayerCheckpointEx(playerid);
            CP[playerid] ++;
            PlayerTextDrawSetString(playerid, InfosTD, "Du-te la ~r~~h~checkpoint-ul~w~~h~ de pe mapa pentru a duce minerul!");
            SetTimerEx("HideTextdraw", 5000, 0, "%d", playerid);
            PlayerTextDrawShow(playerid, InfosTD);     
            new rand = random(2);
            switch(rand) {
                case 0: SetPlayerCheckpointEx(playerid,-2079.0068,-884.1394,32.1719,2.0); // cp
                case 1: SetPlayerCheckpointEx(playerid,-2081.6643,-931.5534,32.1719,2.0); // cp
            }
        }
 
    case 173: {
            DisablePlayerCheckpointEx(playerid);
            CP[playerid] --;   
            PlayerTextDrawSetString(playerid, InfosTD, "Du-te la ~r~~h~checkpoint-ul~w~~h~ de pe mapa pentru a mina din nou minereurile!");
            SetTimerEx("HideTextdraw", 5000, 0, "%d", playerid);
            PlayerTextDrawShow(playerid, InfosTD);         
            new rand = random(3);
            DisablePlayerCheckpointEx(playerid);
            switch(rand) {
                case 0: {
                    SetPlayerCheckpointEx(playerid, -1716.2394,-2134.1418,50.6371, 2.0);           
                }
                case 1: {
                    SetPlayerCheckpointEx(playerid, -973.7756,-1484.9133,93.5230, 2.0);
                }
                case 2: {  
                    SetPlayerCheckpointEx(playerid, -1785.0052,-1317.6433,33.2301, 2.0);
                }
            }
            PlayerInfo[playerid][pMinerSkill] ++;
            UpdateVar(playerid, "MinerSkill", PlayerInfo[playerid][pMinerSkill]);
            GiveJobSalary(playerid);
        }      
    }

La case 172: ai avut rand = random(1), si 2 variante, case 0 si case 1. Functia random e un numar aleatoriu incepand de la 0 pana la nr maxim(x-1), de exemplu tu ai pus random(1), adica functia il putea folosea doar pe case 0 nu si pe case 1 si de aceea ti-a dat eroare, e ca un string doar ca la string nu iti da eroare ci nu ti-l afiseaza pur si simplu in chat mesajul respectiv, cred ca intelegi la ce ma refer, e la fel si la case 173, ti-am modificat doar liniile new rand = random(x);

Nu asa functioneaza.... random(1) inseamna random dintre 0 sau 1, si chiar daca ar fii cum zici tu, nu ar da eroare pentru asa ceva...

Respecta si vei fi respectat.

 

BigInt Pawn:

Pacman C++: 

Snake C++:

Minesweeper C++:

 

mattbb.cash

leaks.ro

Link to comment
Share on other sites

fratii mei sunteti idioti? primeste eroare aia ca a uitat un ";" sau ":" sau mai vad o eroare acolo ca un caz nu este in switch()

Toate erorile alea sunt din cauza faptului ca el a facut case-uri fara sa le puna intr-un switch, am specificat mai sus.

 

EDIT: Codul lui este in regula, trebuie doar sa puna totul intr-un switch.

Edited by iMatt

Respecta si vei fi respectat.

 

BigInt Pawn:

Pacman C++: 

Snake C++:

Minesweeper C++:

 

mattbb.cash

leaks.ro

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...