ID Problem.
#1

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:
Код HTML:
Drugs: 96
It would need to show "Drugs 450", but I look for id 2 of the database.

Reply
#2

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.
Reply
#3

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:
Код HTML:
Drugs: 96
It would need to show "Drugs 450", but I look for id 2 of the database.

This is time to go to sleep.
Reply
#4

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?
Reply
#5

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.
Reply
#6

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
Reply
#7

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.
Reply
#8

Thanks, +1 ALL.
Reply
#9

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]
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)