Little coding questions - For general minor queries 5

How can i use the symbol @ on macros that has parameters?
Example: #define macro(@0, @1).
I just know how to use the symbol % on macros with parameters.
Reply

Is this possible to make two comparaison in one?
Like :
PHP код:
GetVehicleModel(GetPlayerVehicleID(playerid)) == || GetVehicleModel(GetPlayerVehicleID(playerid)) == 
->
PHP код:
GetVehicleModel(GetPlayerVehicleID(playerid)) == 
I thought the logical OR would work but no, it's adding.
Reply

I made a NPC driving a train around the whole San Andreas but it's lagging sometimes (going forward and backing), why? This can be caused by my lag while recording the target or the brake of the train? The NPC only doesn't lag when its speed is very low.
Reply

Quote:
Originally Posted by H4RR1s
View Post
Hi, i have 0 % Scripting knowledge ( Literally 0 % ) But i am willing to start learning.

I have the time and patience for it.

Where should i start?
And what do i need ?
If you need to start in 2017, then it's too late as I think, however, as Paulice suggested, download the SA-MP server, set up your IDE, download important includes such as Streamer, MySQL, Sscanf, etc. and start editing a script of a genre you like. I myself started as by editing scripts and now I can write my own. (I chose COD script, spent about 1 and a half year working on it and abandoned it 7+ months ago) You may then host that script on a free server @ Ultra-H or port forward it to your friends and ask them for finding bugs, ask for suggestions and implement features as you like. As to your signature, I think you're going to prefer RP gamemode over a TDM (I can be wrong though).

Don't start editing by just editing and adding custom messages, textdraw changes, etc. come up with something better and unique, such as adding your own feature and asking for help from the community you got here, You also have a huge amount of content to learn from and improve yourself. Last but not least, learn to code with passion and not copy-paste.
Reply

Quote:
Originally Posted by Logic_
View Post
If you need to start in 2017, then it's too late as I think, however, as Paulice suggested, download the SA-MP server, set up your IDE, download important includes such as Streamer, MySQL, Sscanf, etc. and start editing a script of a genre you like. I myself started as by editing scripts and now I can write my own. (I chose COD script, spent about 1 and a half year working on it and abandoned it 7+ months ago) You may then host that script on a free server @ Ultra-H or port forward it to your friends and ask them for finding bugs, ask for suggestions and implement features as you like. As to your signature, I think you're going to prefer RP gamemode over a TDM (I can be wrong though).

Don't start editing by just editing and adding custom messages, textdraw changes, etc. come up with something better and unique, such as adding your own feature and asking for help from the community you got here, You also have a huge amount of content to learn from and improve yourself. Last but not least, learn to code with passion and not copy-paste.
Hey. I do not agree at all. It's never too late to learn something!
Well, I've read a tutorial in my native language which learned me a lot of things about programming and Pawn. I make my own gamemode and added features and features, more and more complex and yeah, look out some gamemode, see how this is works, check if you can do the same thing by yourself.
Do not start a RP gamemode. This too hard for a begginner I guess.
Reply

Hi there,
I'm trying to revert the values of the column to the default one, but I'm not sure how can I do it. I've posted my SQL(ite) table below. Thanks.

PHP Code:
CREATE TABLE IF NOT EXISTS `Gangs` (`GangIDINTEGER PRIMARY KEY AUTOINCREMENT, `GangNameSTRING DEFAULT 'Null', `GangMotdSTRING DEFAULT 'Null', `GangMembersINTEGER DEFAULT 0, `GangRank1STRING DEFAULT 'Rank 1', `GangRank2STRING DEFAULT 'Rank 2', `GangRank3STRING DEFAULT 'Rank 3', `GangRank4STRING DEFAULT 'Rank 4', `GangRank5STRING DEFAULT 'Rank 5', `GangRank6STRING DEFAULT 'Rank 6'
Reply

This ? https://en.wikipedia.org/wiki/Insert_(SQL)
Reply

Quote:
Originally Posted by Hunud
View Post
That's absolutely what I'm not trying do. I believe you've no expereince in SQL and you've just posted this to increase your post count.
Reply

Looking for a game-mp account for sale or monthly hosted tab listing, pm me.
Reply

Quote:
Originally Posted by Logic_
View Post
Hi there,
I'm trying to revert the values of the column to the default one, but I'm not sure how can I do it. I've posted my SQL(ite) table below. Thanks.

PHP Code:
CREATE TABLE IF NOT EXISTS `Gangs` (`GangIDINTEGER PRIMARY KEY AUTOINCREMENT, `GangNameSTRING DEFAULT 'Null', `GangMotdSTRING DEFAULT 'Null', `GangMembersINTEGER DEFAULT 0, `GangRank1STRING DEFAULT 'Rank 1', `GangRank2STRING DEFAULT 'Rank 2', `GangRank3STRING DEFAULT 'Rank 3', `GangRank4STRING DEFAULT 'Rank 4', `GangRank5STRING DEFAULT 'Rank 5', `GangRank6STRING DEFAULT 'Rank 6'
Delete the row. It's no use to store a row full of null values. If your gamemode cannot function without the presence of a specific row in a database then that is a design flaw. This table is also not properly normalized. Ideally you would have an extra table to store the rank names which would have three columns: gangid, rank sequence number and the actual name. In that way you also don't limit yourself to six. If you want to remove a rank you just delete that row from the table.
Reply

I'm having a problem:

Код:
for(new f = 0, t = 0; f < MAX_PLAYERS, t < 5; f++)
{
	if(!IsPlayerConnected(f))
		continue;
						
	if(strfind(ReturnName(f, 0), params, true) != -1)
	{
		matchesFound[t] = f;
		t++; 
	}
}
This continues to return INVALID_PLAYER_ID and I haven't got a single clue as to why.
Код:
[debug]  Attempted to read/write array element at index 65536 in array of size 50
The error originates from the strfind.

It calls INVALID_PLAYER_ID for ReturnName() and causes it to crash I assume.
Код:
[debug] #0 0005856c in ReturnName (playerid=65536, underScore=0) at macc.pwn:7239
Reply

Quote:
Originally Posted by Arthur Kane
Посмотреть сообщение
I'm having a problem:

Код:
for(new f = 0, t = 0; f < MAX_PLAYERS, t < 5; f++)
{
	if(!IsPlayerConnected(f))
		continue;
						
	if(strfind(ReturnName(f, 0), params, true) != -1)
	{
		matchesFound[t] = f;
		t++; 
	}
}
This continues to return INVALID_PLAYER_ID and I haven't got a single clue as to why.
Код:
[debug]  Attempted to read/write array element at index 65536 in array of size 50
The error originates from the strfind.

It calls INVALID_PLAYER_ID for ReturnName() and causes it to crash I assume.
Код:
[debug] #0 0005856c in ReturnName (playerid=65536, underScore=0) at macc.pwn:7239
Post ReturnName's code!
Reply

ReturnName isn't relevant. The loop is returning INVALID_PLAYER_ID and calling it with ReturnName.
Reply

Quote:
Originally Posted by Arthur Kane
Посмотреть сообщение
ReturnName isn't relevant. The loop is returning INVALID_PLAYER_ID and calling it with ReturnName.
Do you not know what "IsPlayerConnected" does?
Reply

Obviously.

I got the error before I had IsPlayerConnected() and it still happens with it. I added it to see if there would be a difference. I really don't see how it's occurring.
Reply

Quote:
Originally Posted by Arthur Kane
Посмотреть сообщение
Obviously.

I got the error before I had IsPlayerConnected() and it still happens with it. I added it to see if there would be a difference. I really don't see how it's occurring.
Then post the function's code! I have absolutely no clue as to why you would refuse, it's with no doubt not a function out of this world, that's very valuable...

There's nothing wrong with your loop!
Reply

Код:
stock ReturnName(playerid, underScore = 1)
{
	new playersName[MAX_PLAYER_NAME], Name[MAX_PLAYER_NAME];
	
	if(underScore)
	{
		GetPlayerName(playerid, Name, sizeof(Name));
		playersName = Name; 
	}
	else
	{
	         GetPlayerName(playerid, Name, sizeof(Name));
		strreplace(Name, '_', ' '); 
			
		playersName = Name;
	}
	return playersName; 
}
Here you go.
Reply

You must use strcat, format or strcpy (macro) to copy a string to another string. Although this isn't needed in actuality, try this:
PHP код:
new params[] = "Paulice"matchesFound[MAX_PLAYERS];
for(new 
0GetPlayerPoolSize(), 0<= j++)
{
    if(
IsPlayerConnected(i) && strfind(ReturnName(i0), paramstrue) != -1)
    {
        
matchesFound[++] = i;
        if(
>= 5)
        {
            break;
        }
    }
}
stock ReturnName(playeridunderScore 1)
{
    new 
playersName[MAX_PLAYER_NAME 1];
    
GetPlayerName(playeridplayersNamesizeof(playersName));
    if(!
underScore)
    {
        for(new 
0strlen(playersName); j++)
        {
            if(
playersName[i] == '_')
            {
                
playersName[i] = ' ';
            }
        }
    }
    return 
playersName;

GetPlayerPoolSize() exists. Use it (if you're on 0.3.7)!

Strreplace must support multiple characters for search and replace parameter, when one is only required you could simplify things and make it more optimized with a simple loop, an if-then and a replacement code. Strfind can become slow (if that's what it uses)!
Reply

Yeah that worked. Do you know what caused the problem with my code though? I don't understand what it was.
Reply

ReturnName I guess.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)