SA-MP Forums Archive
Problem with code... - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Problem with code... (/showthread.php?tid=254134)



Problem with code... - Narxon - 09.05.2011

Hello again, I have a problem:
above all, I have this: #define strcpy(%0,%1,%2) %0[0]=0;strcat(%0,%2,%1)
the error is in this line:
strcpy (CuentaInfo [playerid] [cuPremium], 64, GetCuentaData (playerid, "Premium"));
And these are the errors ...
C: \ Users \ Benny \ Desktop \ OSRP 2 \ pawno \ include \ cuentas.inc (328 ) : warning 215: expression has no effect
C: \ Users \ Benny \ Desktop \ OSRP 2 \ pawno \ include \ cuentas.inc (328 ) : error 001: expected token: "", pero found "["
C: \ Users \ Benny \ Desktop \ OSRP 2 \ pawno \ include \ cuentas.inc (328 ) : error 029: invalid expression, assumes zero
C: \ Users \ Benny \ Desktop \ OSRP 2 \ pawno \ include \ cuentas.inc (328 ) : warning 215: expression has no effect
C: \ Users \ Benny \ Desktop \ OSRP 2 \ pawno \ include \ cuentas.inc (328 ) : error 001: expected token: "", pero found "]"
C: \ Users \ Benny \ Desktop \ OSRP 2 \ pawno \ include \ cuentas.inc (328 ) : fatal error 107: too many error messages on one line
Function:
Код:
GetCuentaData(playerid, campo[])
{
   print("Inicio de GetCuentaData...");
    new tmp[128];
    new row[60];
    format(tmp, 128, "SELECT %s FROM cuentas WHERE Nombre = '%s' LIMIT 1", campo, pNameEx(playerid));
    mysql_query(tmp);
    mysql_store_result();
    mysql_fetch_row(row);
    mysql_free_result();
    return row;
}
The premium field is not a string, but if I put just CuentaInfo [playerid] [cuPremium] = GetCuentaData (playerid, "Premium") shows this error: Error 006: Must Be Assigned to an array
I hope you can help me: S

edit: Ops fail! I wrote it in Spanish instead of English XD sorry!


Re: Problem with code... - coole210 - 09.05.2011

I edited my function for you..

Код:
stock GetCuentaData(playerid[],campo[],table[]="cuentas")
{
	new returnit[256];
	new string2[256];
	print("Inicio de GetCuentaData...");
	format(string2,sizeof(string2),"SELECT %s FROM %s WHERE Nombre = '%s' LIMIT 1",campo,table,pNameEx(playerid));
	mysql_ping();
	mysql_query(string2);
	mysql_store_result();
	mysql_fetch_row(returnit,"|");
	mysql_free_result();
	return returnit;
}



Re: Problem with code... - Vince - 09.05.2011

Well, you're returning a string from your function, so to convert it to an integer you should use strval.


Re: Problem with code... - MadeMan - 09.05.2011

Show your CuentaInfo enum.