Need help with House Search in gps
#20

Sometimes, mistakes in some codes can also lead to lots of warnings, so you check the compiler log and fix the errors that you've got, and then attempt to fix other errors that may pop up.

Your script will not compile if you've errors, but it'll still compile if you're warnings. So more priority should be given to the errors, this doesn't mean that you completely ignore them, but yet, as I said before in my first paragraph.

--

Quote:
Originally Posted by GTLS
Посмотреть сообщение
Dont run the loop size of HInfo. Run it to MAX_HOUSES.

PHP код:
//Define this if you dont have to number of your max houses.
#define MAX_HOUSES 200
for(new i=0i<sizeof(MAX_HOUSES); i++) 
This code is, in fact, wrong. sizeof can only be used for variables, not pre-processor defines. However, both are valid, i < sizeof HausInfo or i < MAX_HOUSES.

Please think for a minute before you post.

--

The code of yours @OP, is slow.

You're running the loop the times of the MAX_HOUSES/ size of the House array, then you're converting the string (inputtext) to an integer and then comparing it, just convert the stuff beforehand you run the loop.

PHP код:
if(dialogid == NAVIDIALOGHAUS)
{
    if (!
response) return 1;
    if(!
IsNumeric(inputtext)) return SendClientMessage(playeridCOLOR_RED"Du kannst nur Zahlen eingeben.");
    new 
value strval(inputtext);
    for(new 
i=0i<sizeof(hausInfo); i++)
    {
        if(
value == hausInfo[i][hausnummer])
        {
            
SetPlayerCheckpoint(playeridhausInfo[i][hx], hausInfo[i][hy], hausInfo[i][hz], 5);
            
SendClientMessage(playeridCOLOR_WHITE"Das Haus wurde auf der Karte markiert.");    
            return 
1;
        }
        else
        {
            
SendClientMessage(playeridCOLOR_RED"Die Hausnummer gibt es nicht.");
            break;
        }
        return 
1;
    }

A good tip for you'll be that you decrease the usage of brackets, and make your statements straight forward, like in my code!

However, there may be other errors in the code since I've just assumed some stuff on my own since I don't know what the original 'HausInfo' variable is.
Reply


Messages In This Thread
Need help with House Search in gps - by ImTobi - 01.06.2018, 23:54
Re: Need help with House Search in gps - by DarkSkull - 02.06.2018, 00:27
Re: Need help with House Search in gps - by GTLS - 02.06.2018, 05:52
Re: Need help with House Search in gps - by ImTobi - 02.06.2018, 10:38
Re: Need help with House Search in gps - by ImTobi - 02.06.2018, 10:42
Re: Need help with House Search in gps - by ImTobi - 02.06.2018, 15:52
Re: Need help with House Search in gps - by GTLS - 03.06.2018, 06:26
Re: Need help with House Search in gps - by ImTobi - 03.06.2018, 10:18
Re: Need help with House Search in gps - by GTLS - 03.06.2018, 10:32
Re: Need help with House Search in gps - by ImTobi - 03.06.2018, 11:03
Re: Need help with House Search in gps - by GTLS - 03.06.2018, 11:14
Re: Need help with House Search in gps - by ImTobi - 03.06.2018, 11:22
Re: Need help with House Search in gps - by ImTobi - 03.06.2018, 20:02
Re: Need help with House Search in gps - by ImTobi - 05.06.2018, 23:38
Re: Need help with House Search in gps - by ImTobi - 07.06.2018, 14:57
Re: Need help with House Search in gps - by DaniceMcHarley - 07.06.2018, 15:43
Re: Need help with House Search in gps - by ImTobi - 08.06.2018, 12:28
Re: Need help with House Search in gps - by jasperschellekens - 08.06.2018, 13:33
Re: Need help with House Search in gps - by ImTobi - 08.06.2018, 19:37
Re: Need help with House Search in gps - by Logic_ - 09.06.2018, 03:17
Re: Need help with House Search in gps - by ImTobi - 09.06.2018, 10:26

Forum Jump:


Users browsing this thread: 1 Guest(s)