ID Problem. - 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)
+--- Thread: ID Problem. (
/showthread.php?tid=587359)
ID Problem. -
norton2 - 30.08.2015
I have a problem with the ID safes!
Код HTML:
CMD:debug(playerid, params [])
{
printf("Drugs: %d", Safes[1][Drugs]); // [1] = Safe ID from Database MYSQL.
return 1;
}
.log:
It would need to show "Drugs 450", but I look for id 2 of the database.
Re: ID Problem. -
Mariciuc223 - 30.08.2015
start from 0.
Код HTML:
printf("Grove Drugs: %d", Safes[0][Drugs]); // [1] = Safe ID from Database MYSQL.
printf("Balla' Drugs: %d", Safes[1][Drugs]); // [1] = Safe ID from Database MYSQL.
Re: ID Problem. -
Logofero - 30.08.2015
Quote:
Originally Posted by norton2
I have a problem with the ID safes!
Код HTML:
CMD:debug(playerid, params [])
{
printf("Drugs: %d", Safes[1][Drugs]); // [1] = Safe ID from Database MYSQL.
return 1;
}
.log: It would need to show "Drugs 450", but I look for id 2 of the database.

|
This is time to go to sleep.
Re: ID Problem. -
norton2 - 30.08.2015
Quote:
Originally Posted by Mariciuc223
start from 0.
Код HTML:
printf("Grove Drugs: %d", Safes[0][Drugs]); // [1] = Safe ID from Database MYSQL.
printf("Balla' Drugs: %d", Safes[1][Drugs]); // [1] = Safe ID from Database MYSQL.
|
If you go from 0 everything is ok, but you can not go from ID 1?
Re: ID Problem. -
Mariciuc223 - 30.08.2015
Quote:
Originally Posted by norton2
If you go from 0 everything is ok, but you can not go from ID 1?
|
Always start from 0.
Re: ID Problem. -
Logofero - 30.08.2015
Quote:
Originally Posted by norton2
If you go from 0 everything is ok, but you can not go from ID 1?
|
The database is always counting from 1. In SQLite too MySQL everywhere
Re: ID Problem. -
HazardouS - 30.08.2015
Quote:
Originally Posted by norton2
If you go from 0 everything is ok, but you can not go from ID 1?
|
A PAWN array's index starts from 0. This means that if you do "new Array[2];", you will be able to access Array[0] and Array[1]. Any other cells won't have any memory allocated, so trying to access them will result in an error (Array[2], Array[3] etc). If, for some reason, you want to skip index 0 and start from 1, you have to declare your initial array 1 cell bigger, so if you have 2 elements that you want to store in this kind of array, you will have to do "new Array[3];". Then, you will be able to access them by "Array[1]" and "Array[2]". But this means that you will keep 1 cell of memory occupied but not used, which is not good practice. Sure, you can do this in a specific place where it would be way harder to do it correctly (starting from 0), but don't even think to do it everywhere.
Re: ID Problem. -
norton2 - 30.08.2015
Thanks, +1 ALL.
Re: ID Problem. -
Riversong - 13.09.2015
D:\SAMP\gamemodes\bare.pwn(31) : error 035: argument type mismatch (argument 1)
D:\SAMP\gamemodes\bare.pwn(32) : error 017: undefined symbol "mysql_store_result"
D:\SAMP\gamemodes\bare.pwn(2

: warning 204: symbol is assigned a value that is never used: "string"
Getting this shit right after entering the first piece of code into onConnect.
Got include a_mysql on top.
Got the plugin from the link installed. Latest one.
Wtf is wrong with it?
Also, the creators website is dead [domain for sale]