SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 09/06/2018, 10:26 AM   #21
ImTobi
Big Clucker
 
ImTobi's Avatar
 
Join Date: Jun 2017
Posts: 144
Reputation: 3
Default Re: Need help with House Search in gps

Quote:
Originally Posted by Logic_ View Post
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.

--



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 Code:
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.

Code:
enum HausEnum
{
	Float:hx,
	Float:hy,
	Float:hz,
	Float:ihx,
	Float:ihy,
	Float:ihz,
	hinterior,
	hbesitzer[MAX_PLAYER_NAME],
	hid,
	hpickup,
	Text3D:htext,
	hpreis,
	hvirtualworld,
	locked
}

Code:
new hausInfo[1000][HausEnum];
ImTobi is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[FilterScript] Cali-Houses: Create a house anywhere, dynamic house creating! California Filterscripts 257 31/05/2018 02:23 AM
[FilterScript] h-House: Create a house anywhere, dynamic house creating! HY Filterscripts 6 23/02/2015 06:36 AM
Gagi's House System's House cords problem Wahaj Scripting Help 2 03/07/2014 03:15 PM
Help me for house bug , stats ID : house 1 , house 2 Owner jesdynguyen Scripting Help 1 02/06/2014 05:57 AM
Search, SII house system wofka13 Help Archive 2 17/06/2010 02:05 AM


All times are GMT. The time now is 10:53 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.