Re: Little coding questions - For general minor queries 5 -
several - 09.11.2017
Hy,
How do you get data from 3-D array ?
Something like this doesn't work
Код:
new someArray[3][2][] =
{
{"One" ,1},
{"Two" ,2},
{"Four" ,3},
};
...
new someVar = someArray[0][1];
but this works
Код:
printf("%s %i" ,someArray[1][0] ,someArray[1][1]);
Re: Little coding questions - For general minor queries 5 -
Nero_3D - 09.11.2017
Quote:
Originally Posted by several
How do you get data from 3-D array ?
|
You array has 3 rows, 2 columns and each field is an array, although 1, 2, 3 don't look like one
Lets add the brackets to make it clear, it should look like that
PHP код:
new someArray[3][2][] =
{
{"One" , {1}},
{"Two", {2}},
{"Four", {3}}
};
// or like that if you represent the string as array
new someArray2[3][2][] =
{
{
{'O', 'n', 'e', EOS},
{1}
}, {
{'T', 'w', 'o', EOS},
{2}
}, {
{'F', 'o', 'u', 'r', EOS},
{3}
}
};
With that it should be clear that you need to do
PHP код:
new someVar = someArray[0][1][0];
printf does work because it only gets the address, you could even print someArray or someArray[0] if you want
Re: Little coding questions - For general minor queries 5 -
several - 09.11.2017
Quote:
Originally Posted by Nero_3D
You array has 3 rows, 2 columns and each field is an array, although 1, 2, 3 don't look like one
Lets add the brackets to make it clear, it should look like that
PHP код:
new someArray[3][2][] =
{
{"One" , {1}},
{"Two", {2}},
{"Four", {3}}
};
// or like that if you represent the string as array
new someArray2[3][2][] =
{
{
{'O', 'n', 'e', EOS},
{1}
}, {
{'T', 'w', 'o', EOS},
{2}
}, {
{'F', 'o', 'u', 'r', EOS},
{3}
}
};
With that it should be clear that you need to do
PHP код:
new someVar = someArray[0][1][0];
printf does work because it only gets the address, you could even print someArray or someArray[0] if you want
|
Ehhh ,I'm an idiot ,thanks.
Re: Little coding questions - For general minor queries 5 -
several - 10.11.2017
Sorry for reposting but i was wondering if something like this was possible in pawn:
Код:
enum CORD
{
Float:X,
Float:Y,
Float:Z,
INT,
VW
}
stock pPos(id ,& CORD:cord)
{
cord[INT] = GetPlayerVirtualWorld(id);
cord[VW] = GetPlayerInterior(id);
GetPlayerPos(id ,cord[X] ,cord[Y] ,cord[Z]);
}
...
new pos[CORD];
pPos(playerid ,pos);
instead of
Код:
stock pPos(id ,& Float:x ,& Float:y ,...)
...
new pos[CORD];
pPos(playerid ,pos[X] ,pos[Y] ,...);
Re: Little coding questions - For general minor queries 5 -
IstuntmanI - 10.11.2017
Quote:
Originally Posted by several
<>
|
Sure, but the enum is just an enumerator, you can't pass it directly as a parameter like that, you need an array with the first dimension set as that enum so you have where to store the new values:
PHP код:
enum gePosInfo
{
Float:X,
Float:Y,
Float:Z,
INT,
VW
}
stock GetPlayerPosInfo( playerid, posInfo[ gePosInfo ] ) // you don't need & because arrays are automatically passed by reference
{
posInfo[ INT ] = GetPlayerVirtualWorld( playerid );
posInfo[ VW ] = GetPlayerInterior( playerid );
GetPlayerPos( playerid, posInfo[ X ], posInfo[ Y ], posInfo[ Z ] );
}
public OnPlayerUpdate( playerid )
{
new lPosInfo[ gePosInfo ] = { -1.0, -1.0, -1.0, -1, -1 };
printf( "Before: %f %f %f %d %d", lPosInfo[ X ], lPosInfo[ Y ], lPosInfo[ Z ], lPosInfo[ INT ], lPosInfo[ VW ] ); // prints -1.0, -1.0, -1.0, -1, -1
GetPlayerPosInfo( playerid, lPosInfo );
printf( "After: %f %f %f %d %d", lPosInfo[ X ], lPosInfo[ Y ], lPosInfo[ Z ], lPosInfo[ INT ], lPosInfo[ VW ] ); // prints correct values
return 1;
}
Also, about your 3D array problem: it is way better to use enums in that case:
PHP код:
enum someEnum
{
someString[ 8 ], // max string size is 8
someVar
};
new someArray[ 3 ][ someEnum ] =
{
{ "One", 1 },
{ "Two", 2 },
{ "Four", 3 }
};
// get elements:
for( new i = 0; i < sizeof( someArray ); i ++ )
{
printf( "someArray[ %d ] = { '%s', %d }", i, someArray[ i ][ someString ], someArray[ i ][ someVar ] );
}
With this method only what you need will be an actual sub-array: the string in this case (in Pawn, a string is an array of characters [represented by
ASCII values]), without setting the integer as an array too, which made no sense and is bad. Using enum in that case also offers more protection at compile time and you can easily access them by using the name of the element.
Re: Little coding questions - For general minor queries 5 -
axellech - 11.11.2017
Is it possible to put the server maps out of gamemode? without filterscript?
What code do I have to do to do this?
like:
PHP код:
"#include "..modules\maps\house.pwn"
But if I do, what, what code should I put in
house.pwn to put the map in?
Re: Little coding questions - For general minor queries 5 -
Eoussama - 11.11.2017
Quote:
Originally Posted by axellech
Is it possible to put the server maps out of gamemode? without filterscript?
What code do I have to do to do this?
like:
PHP код:
"#include "..modules\maps\house.pwn"
But if I do, what, what code should I put in house.pwn to put the map in?
|
Yes, it should be as followed.
PHP код:
//house.pwn
CreateHouses()
{
CretaeDynamicObject(.....);
CretaeDynamicObject(.....);
CretaeDynamicObject(.....);
//.....
CretaeDynamicObject(.....);
CretaeDynamicObject(.....);
}
PHP код:
//your gaemode file
OnGamemodeInIt()
{
CreateHouses();
return 1;
}
Re: Little coding questions - For general minor queries 5 -
axellech - 12.11.2017
Quote:
Originally Posted by Eoussama
Yes, it should be as followed.
PHP код:
//house.pwn
CreateHouses()
{
CretaeDynamicObject(.....);
CretaeDynamicObject(.....);
CretaeDynamicObject(.....);
//.....
CretaeDynamicObject(.....);
CretaeDynamicObject(.....);
}
PHP код:
//your gaemode file
OnGamemodeInIt()
{
CreateHouses();
return 1;
}
|
Thank you <3
Re: Little coding questions - For general minor queries 5 -
axellech - 16.11.2017
How to put a
custom texture on "room decorating images" objects?
"custom images into object, how to do this?"
Re: Little coding questions - For general minor queries 5 -
Logic_ - 20.11.2017
i need some help here
PHP код:
error 001: expected token: "-string end-", but found "-identifier-"
warning 215: expression has no effect
error 001: expected token: ";", but found ")"
error 029: invalid expression, assumed zero
fatal error 107: too many error messages on one line
non-formatted messages work fine, using format causes the above mentioned problems.
all these errors coming from
PHP код:
new str[70];
format(str, sizeof str, "You can't chat while you're muted, you must wait %d seconds.", PlayerStat[playerid][MuteTime]);
SendErrorMessage(playerid, str); // this line
definition of SendErrorMessage
PHP код:
#define SendErrorMessage(%1,%2) \
SendClientMessage(%1, COLOR_PINK, "[ERROR] {FFFFFF} " %2)
Re: Little coding questions - For general minor queries 5 -
rfr - 01.12.2017
Quote:
Originally Posted by GaByM
PHP код:
#include <a_samp>
main()
{
new k;
if(k)
return 1;
else
{
}
return 1;
}
PHP код:
D:\SERVER\gamemodes\a.pwn(10) : warning 225: unreachable code
Why?
|
PHP код:
#include <a_samp>
main()
{
new k;
if(k)
return 1;
else if (!k)
{
}
return 1;
}
try this.
Re: Little coding questions - For general minor queries 5 -
Mister0 - 01.12.2017
Hi, this error "Array index out of bounds" show when you acces an element past over you defined variable like new variable[20] and you acces 20 or 21 etc.
So I have this error
Код:
[20:58:23] [debug] AMX backtrace:
[20:58:23] [debug] #0 00068d9c in ?? (1) from rpggm.amx
[20:58:23] [debug] #1 001c3860 in public TimerSeconds () from rpggm.amx
[20:58:24] [debug] Run time error 4: "Array index out of bounds"
[20:58:24] [debug] Accessing element at index 27 past array upper bound 25
so this error show me I have a variable [26] and I acces upper element, but I can sure you I have no variable with value [24] [25] or [26]
So I ask you what else can produce this error?
Re: Little coding questions - For general minor queries 5 -
Mister0 - 01.12.2017
Solved thx anyway
Re: Little coding questions - For general minor queries 5 -
GaByM - 02.12.2017
When using mysql_tquery, should I use cache_delete(x) if I don't use cache_save()? AFAIK the result isn't stored by default, but I want to be sure, so I won't get memory leaks.
Re: Little coding questions - For general minor queries 5 -
NealPeteros - 02.12.2017
I'm not really good at mapping. Is it possible for the text of the object below to be changed?
Re: Little coding questions - For general minor queries 5 -
NealPeteros - 02.12.2017
Quote:
Originally Posted by [HLF]Southclaw
Yeah you can change that, either via SetObjectMaterialText or (when 0.3.8 comes out) via changing the texture and providing the new object+texture as a downloadable asset.
|
Used SetObjectMaterialText but had a little problem
Код:
new obj0 = CreateObject(3715, 1362.1599, -1036.0848, 31.3095, 0.0000, 0.0000, 84.1780);
SetObjectMaterialText(obj0, "SAMPTESTSAMPTEST SAMPTEST", 2, 120, "Castellar", 60, 0, 0xFFFFFFFF, 0xFF000000, 2);
RESULT:
Re: Little coding questions - For general minor queries 5 -
NealPeteros - 02.12.2017
Quote:
Originally Posted by [HLF]Southclaw
You'll have to just pad it with spaces, there's sadly no way to alter UV coordinates with material functions.
|
It still doesn't work, the same result.
Re: Little coding questions - For general minor queries 5 -
Dayrion - 03.12.2017
Which one is preferable to update the car's health?
- Using OnPlayerUpdate and checking if the player is inside a vehicle
- A timer though every vehicle running every second/500 ms
- A timer though every player running every second/500ms
Re: Little coding questions - For general minor queries 5 -
Dayrion - 03.12.2017
Quote:
Originally Posted by [HLF]Southclaw
The answer would depend on your average player count, amount of vehicles and future scale plans.
|
Yep, obivously. My bad.
Average 60-80 players & +1000 vehicles.
I'm asking myself between a timer and OnPlayerUpdate. I find the timer will be not accurate for the vehicle's health and OnPlayerUpdate is called too much time for this use.
Re: Little coding questions - For general minor queries 5 -
Lucases - 03.12.2017
Use a timer. As you said OnPlayerUpdate gets called 30+ times in a second, so isn't very efficient when there are a lot of players driving