Jump to content
  • 0

eroare compilare - pawn compiler - ultima versiune


Question

Posted

Buna, 

 

Am facut UPDATE la pawn compiler si primesc eroarea asta:

 

error 092: functions may not return arrays of unknown size (symbol "Adrian")

asta e linia: 

Adrian(playerid, A, PlayerInfo[playerid][pLoserLevel]);

 

si acesta este stock-ul: 

stock Adrian(playerid, string[], V)
{
	new A, B, C;
	if(!V)
	{
	    switch(random(5))
	    {
	        case 0: V = 1;
	        case 1: V = 3;
	        case 2: V = 5;
	        case 3: V = 7;
	        case 4: V = 9;
	    }
	    PlayerInfo[playerid][pLoserLevel] = V;
	}
	switch(V)
	{
		case 1:
		{
			A = 3;
			B = 4;
			C = 7;
		}
		case 3:
		{
			A = 8;
			B = 9;
			C = 1;
		}
		case 5:
		{
			A = 3;
			B = 7;
			C = 4;
		}
		case 7:
		{
			A = 1;
			B = 3;
			C = 9;
		}
		case 9:
		{
			A = 5;
			B = 2;
			C = 6;
		}
	}
	for(new i, l = strlen(string); i < l; i++)
	{
		switch(string[i])
		{
		    case 48..57:
			{
				string[i] += A;
				if(string[i] > 57) string[i] -= 10;
			}
		    case 65..90:
			{
				string[i] += B;
				if(string[i] > 90) string[i] -= 26;
			}
			case 97..122:
			{
			    string[i] += C;
				if(string[i] > 122) string[i] -= 26;
			}
		}
	}
	return string;
}

P.S: ESTE FOLOSIT PENTRU HASH PAROLA, UN FEL DE CRYPT. - eficient.

7 answers to this question

Recommended Posts

  • 0
Posted

Crede-ma nu e nimic efficient sau bun la metoda aia de hash, as folosi bcrypt sau in cel mai rau caz sha256 inclus in sa-mp. Dar nu sutem aici sa dezbatem acest topic

Iti dau doua posibile metode la care ma gandesc eu cum ai putea face, cu singuranta sunt mai multe. In princpiu, problema functiei este faptul ca string nu are o marime declaarata

stock Adrian(playerid, string[], V)
{
	new A, B, C, returnedString[144];
	if(!V)
	{
	    switch(random(5))
	    {
	        case 0: V = 1;
	        case 1: V = 3;
	        case 2: V = 5;
	        case 3: V = 7;
	        case 4: V = 9;
	    }
	    PlayerInfo[playerid][pLoserLevel] = V;
	}
	switch(V)
	{
		case 1:
		{
			A = 3;
			B = 4;
			C = 7;
		}
		case 3:
		{
			A = 8;
			B = 9;
			C = 1;
		}
		case 5:
		{
			A = 3;
			B = 7;
			C = 4;
		}
		case 7:
		{
			A = 1;
			B = 3;
			C = 9;
		}
		case 9:
		{
			A = 5;
			B = 2;
			C = 6;
		}
	}
	for(new i, l = strlen(string); i < l; i++)
	{
		switch(string[i])
		{
		    case 48..57:
			{
				string[i] += A;
				if(string[i] > 57) string[i] -= 10;
			}
		    case 65..90:
			{
				string[i] += B;
				if(string[i] > 90) string[i] -= 26;
			}
			case 97..122:
			{
			    string[i] += C;
				if(string[i] > 122) string[i] -= 26;
			}
		}
	}

	strcpy(returnedString, string);
	return returnedString;
}

Sau

stock Adrian(playerid, const string[], V)
{
	new A, B, C, returnedString[144];

	strcpy(returnedString, string);

	if(!V)
	{
	    switch(random(5))
	    {
	        case 0: V = 1;
	        case 1: V = 3;
	        case 2: V = 5;
	        case 3: V = 7;
	        case 4: V = 9;
	    }
	    PlayerInfo[playerid][pLoserLevel] = V;
	}
	switch(V)
	{
		case 1:
		{
			A = 3;
			B = 4;
			C = 7;
		}
		case 3:
		{
			A = 8;
			B = 9;
			C = 1;
		}
		case 5:
		{
			A = 3;
			B = 7;
			C = 4;
		}
		case 7:
		{
			A = 1;
			B = 3;
			C = 9;
		}
		case 9:
		{
			A = 5;
			B = 2;
			C = 6;
		}
	}
	for(new i, l = strlen(returnedString); i < l; i++)
	{
		switch(returnedString[i])
		{
		    case 48..57:
			{
				returnedString[i] += A;
				if(returnedString[i] > 57) returnedString[i] -= 10;
			}
		    case 65..90:
			{
				returnedString[i] += B;
				if(returnedString[i] > 90) returnedString[i] -= 26;
			}
			case 97..122:
			{
			    returnedString[i] += C;
				if(returnedString[i] > 122) returnedString[i] -= 26;
			}
		}
	}

	return returnedString;
}

In caz ca dintr-un motiv sau altul nu ai strcpy

stock strcpy(dest[], const source[], len = sizeof(dest)) {
	dest[0] = '\0';
	return strcat(dest, source, len);
}

 

  • Thanks 1
  • 0
Posted

Multumesc,

 

Am incercat prima varianta, revin cu UPDATE in caz de problema.

 

 

  • 0
Posted

@VeLo

Aparent, lucru pe care nu il stiam nici eu, array sunt pasate ca si referinta in pawn precum raspunsul pe care l-ai primit aici https://burgershot.gg/showthread.php?tid=1446 sugereaza ceea ce inseamna ca functia ta poate pur si simplu sa fie

stock Adrian(playerid, string[], V)
{
	new A, B, C;
	if(!V)
	{
	    switch(random(5))
	    {
	        case 0: V = 1;
	        case 1: V = 3;
	        case 2: V = 5;
	        case 3: V = 7;
	        case 4: V = 9;
	    }
	    PlayerInfo[playerid][pLoserLevel] = V;
	}
	switch(V)
	{
		case 1:
		{
			A = 3;
			B = 4;
			C = 7;
		}
		case 3:
		{
			A = 8;
			B = 9;
			C = 1;
		}
		case 5:
		{
			A = 3;
			B = 7;
			C = 4;
		}
		case 7:
		{
			A = 1;
			B = 3;
			C = 9;
		}
		case 9:
		{
			A = 5;
			B = 2;
			C = 6;
		}
	}
	for(new i, l = strlen(string); i < l; i++)
	{
		switch(string[i])
		{
		    case 48..57:
			{
				string[i] += A;
				if(string[i] > 57) string[i] -= 10;
			}
		    case 65..90:
			{
				string[i] += B;
				if(string[i] > 90) string[i] -= 26;
			}
			case 97..122:
			{
			    string[i] += C;
				if(string[i] > 122) string[i] -= 26;
			}
		}
	}
}

Si sa o folosesti

new parola[144];
Adrian(playerid, parola, v);

Si parola va contine exact acel hash

  • 0
Posted

in mare parte arata ok, mai am 2 erori gen aici cum definesc marimea?

 

OnPlayerLogin

 

if(PlayerInfo[playerid][pLoserLevel] > 0) Adrian(playerid, password, PlayerInfo[playerid][pLoserLevel]);

peste tot string-ul e de 32 caractere.

  • 0
Posted

Atat timp cat password e de marime 33 (32 + null terminator) adica new password[33] ar trebui sa functioneze. Eventual poti mentiona marimea stringului direct in functie la parametru si sa ai string[33]

  • 0
Posted

eroarea: xyz.pwn(18573) : error 047: array sizes do not match, or destination array is too small

  • 0
Posted

Am facut exact asa,

 

dar primesc

error 047: array sizes do not match, or destination array is too small

 

la: OnPlayerLogin - Adrian(playerid, password, PlayerInfo[playerid][pLoserLevel]);

la OnPlayerRegister - Adrian(playerid, password, 0);

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more details you can also review our Terms of Use and Privacy Policy.