Re: Little coding questions - For general minor queries 5 -
NathanT - 28.06.2017
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.
Re: Little coding questions - For general minor queries 5 -
Dayrion - 29.06.2017
Is this possible to make two comparaison in one?
Like :
PHP код:
GetVehicleModel(GetPlayerVehicleID(playerid)) == 5 || GetVehicleModel(GetPlayerVehicleID(playerid)) == 6
->
PHP код:
GetVehicleModel(GetPlayerVehicleID(playerid)) == 5 | 6
I thought the logical OR would work but no, it's adding.
Re: Little coding questions - For general minor queries 5 -
NathanT - 13.07.2017
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.
Re: Little coding questions - For general minor queries 5 -
Logic_ - 14.07.2017
Quote:
Originally Posted by H4RR1s
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.
Re: Little coding questions - For general minor queries 5 -
Dayrion - 14.07.2017
Quote:
Originally Posted by Logic_
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.
Re: Little coding questions - For general minor queries 5 -
Logic_ - 15.07.2017
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` (`GangID` INTEGER PRIMARY KEY AUTOINCREMENT, `GangName` STRING DEFAULT 'Null', `GangMotd` STRING DEFAULT 'Null', `GangMembers` INTEGER DEFAULT 0, `GangRank1` STRING DEFAULT 'Rank 1', `GangRank2` STRING DEFAULT 'Rank 2', `GangRank3` STRING DEFAULT 'Rank 3', `GangRank4` STRING DEFAULT 'Rank 4', `GangRank5` STRING DEFAULT 'Rank 5', `GangRank6` STRING DEFAULT 'Rank 6')
Re: Little coding questions - For general minor queries 5 -
Hunud - 15.07.2017
This ?
https://en.wikipedia.org/wiki/Insert_(SQL)
Re: Little coding questions - For general minor queries 5 -
Logic_ - 15.07.2017
Quote:
Originally Posted by Hunud
|
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.
Re: Little coding questions - For general minor queries 5 -
Battlezone - 15.07.2017
Looking for a game-mp account for sale or monthly hosted tab listing, pm me.
Re: Little coding questions - For general minor queries 5 -
Vince - 15.07.2017
Quote:
Originally Posted by Logic_
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` (`GangID` INTEGER PRIMARY KEY AUTOINCREMENT, `GangName` STRING DEFAULT 'Null', `GangMotd` STRING DEFAULT 'Null', `GangMembers` INTEGER DEFAULT 0, `GangRank1` STRING DEFAULT 'Rank 1', `GangRank2` STRING DEFAULT 'Rank 2', `GangRank3` STRING DEFAULT 'Rank 3', `GangRank4` STRING DEFAULT 'Rank 4', `GangRank5` STRING DEFAULT 'Rank 5', `GangRank6` STRING 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.
Re: Little coding questions - For general minor queries 5 -
Kane - 30.08.2017
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
Re: Little coding questions - For general minor queries 5 -
Paulice - 30.08.2017
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!
Re: Little coding questions - For general minor queries 5 -
Kane - 30.08.2017
ReturnName isn't relevant. The loop is returning INVALID_PLAYER_ID and calling it with ReturnName.
Re: Little coding questions - For general minor queries 5 -
Paulice - 30.08.2017
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?
Re: Little coding questions - For general minor queries 5 -
Kane - 30.08.2017
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.
Re: Little coding questions - For general minor queries 5 -
Paulice - 30.08.2017
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!
Re: Little coding questions - For general minor queries 5 -
Kane - 30.08.2017
Код:
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.
Re: Little coding questions - For general minor queries 5 -
Paulice - 30.08.2017
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 i = 0, j = GetPlayerPoolSize(), k = 0; i <= j; i ++)
{
if(IsPlayerConnected(i) && strfind(ReturnName(i, 0), params, true) != -1)
{
matchesFound[k ++] = i;
if(k >= 5)
{
break;
}
}
}
stock ReturnName(playerid, underScore = 1)
{
new playersName[MAX_PLAYER_NAME + 1];
GetPlayerName(playerid, playersName, sizeof(playersName));
if(!underScore)
{
for(new i = 0, j = strlen(playersName); i < j; i ++)
{
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)!
Re: Little coding questions - For general minor queries 5 -
Kane - 30.08.2017
Yeah that worked. Do you know what caused the problem with my code though? I don't understand what it was.
Re: Little coding questions - For general minor queries 5 -
Paulice - 30.08.2017
ReturnName I guess.