Little coding questions - For general minor queries 5
#81

Quote:
Originally Posted by [K4L
Leopard ]
Quote:
Originally Posted by Biofreeze
It is possible to refer to a command in a function , without re-typing the code that's used to make the command work ? For example if you created a menu and you want to execute the command ''/help'' if he has chosen " case 0 ". Etc etc.
OnPlayerCommand(playerid, "/help");

Leopard
Oh thanks for clearing that up

EDIT: OnPlayerCommand isent defined. I know how it works with dcmd. But these commands are not separtly functions. So how to define them ?

EDIT2: nvm Fixed. onplayercommandtext >_>
Reply
#82

Code:
public IsAPoliceCar(vehicleid)
{
for(new i=0; i<35; i++)
{
if(vehicleid == copv[i])
{
break;
}
}
return 1;
}
This code should see copv[1] etc etc till copv[34] as a copcar. Instead of that , it sees all cars as a copcar. Where does it go wrong ?

EDIT: fixed , break > return 1; ___ return 1; > return 0; , sry dumbie.
Reply
#83

Does a function like the instr function exist for pawn? Or has anyone made such a function? I think I know how to make something like this but it would be hard and I was just wondering if anyone else had already done this.
Reply
#84

You mean something like strfind?
Reply
#85

Yeah, lol, I was just about to edit it out. I thought strfind just returned like 0 if the string was found. Not the occurance. I just read about it on the wiki though.
Reply
#86

Lol,Im really a beginner here....I know how to edit...but adding command is kinda harder.
When i add between like that /Nrg and /god command then i get bunch of errors...so is that wrong ?
Reply
#87

If the TextDraw isn't for each player diferent, then yes.

How can I change this:
Code:
if(newkeys & KEY_FIRE) {

}
in to a switch:
Code:
switch (newkeys &&) { //something diferent here
case KEY_FIRE: {

}
}
?
Reply
#88

Hello,

I have a question. I cant seem to find the correct gate / fence.

I want a really small door or fence wich fits inside the LSPD jail.
I want to make a moving gate inside LSPD, doing that is easy but I cant find a good Object ID for it.

I hope anyone if you allready done this and has a good ID for me.

Help would be very appriciated!

Kind Regards,
Wes.
Reply
#89

use notepad to view Rockstar Games\GTA San Andreas\data\objects.
Reply
#90

Quote:
Originally Posted by Abs4u
use notepad to view Rockstar Games\GTA San Andreas\data\objects.
Fences, Walls, Gates, and Barriers

966 bar_gatebar01 [966]
968 barrierturn [968]
969 Electricgate [969]
970 fencesmallb [970]
971 subwaygate [971]
972 tunnelentrance [972]
973 sub_roadbarrier [973]
974 tall_fence [974]
975 Columbiangate [975]
976 phils_compnd_gate [976]
978 sub_roadright [978]
979 sub_roadleft [979]
980 airportgate [980]
981 helix_barrier [981]
982 fenceshit [982]
983 fenceshit3 [983]
984 fenceshit2 [984]
985 gate_autoR [985]
986 gate_autoL [986]
987 elecfence_BAR [987]
988 ws_apgate [988]
989 ac_apgate [989]
990 bar_barrier12 [990]
991 bar_barriergate1 [991]
992 bar_barrier10b [992]
993 bar_barrier10 [993]
994 lhouse_barrier2 [994]
995 bar_barrier16 [995]
996 lhouse_barrier1 [996]
997 lhouse_barrier3 [997]
998 Gdyn_barrier17 [998]
1228 roadworkbarrier1 [1228]
1237 strtbarrier01 [1237]
1250 smashbarpost [1250]
1251 smashbar [1251]
1282 Barrierm [1282]
1374 traincross2 [1374]
1407 DYN_F_R_WOOD_1 [1407]
1408 DYN_F_WOOD_2 [1408]
1410 DYN_F_R_WOOD_1b [1410]
1411 DYN_MESH_1 [1411]
1412 DYN_MESH_2 [1412]
1413 DYN_MESH_3 [1413]
1414 DYN_COR_SHEET [1414]
1418 DYN_F_WOOD_3 [1418]
1419 DYN_F_IRON_1 [1419]
1422 DYN_ROADBARRIER_5 [1422]
1423 DYN_ROADBARRIER_4 [1423]
1424 DYN_ROADBARRIER_2 [1424]
1425 DYN_ROADBARRIER_3 [1425]
1427 CJ_ROADBARRIER [1427]
1434 DYN_ROADBARRIER_5a [1434]
1435 DYN_ROADBARRIER_5b [1435]
1446 DYN_F_R_WOOD_4 [1446]
1447 DYN_MESH_4 [1447]
1456 DYN_F_R_WOOD_2 [1456]
1459 DYN_ROADBARRIER_6 [1459]
1460 DYN_F_R_WOOD_3 [1460]
1468 DYN_MESH_05 [1468]
1552 vegasmashfnce [1552]
1553 vegasmashfnce_Gate [1553]
1648 od_groyne01 [1648]
1652 fencehaiti [1652]
1653 fencehaitism [1653]
1662 nt_roadblockCI [1662]
2098 CJ_SLOTCOVER1 [2098]
2395 CJ_SPORTS_WALL [2395]
2400 CJ_SPORTS_WALL01 [2400]
2650 CJ_Skate_wall2 [2650]
2651 CJ_Skate_wall1 [2651]
2755 Dojo_Wall [2755]
3260 oldwoodpanel [3260]
3275 cxreffence [3275]
3276 cxreffencesld [3276]
3282 cxreffencemsh [3282]
3451 vegashsenew2 [3451]
3475 vgsn_fncelec_pst [3475]
3550 vgsn_fncelec_msh [3550]
3749 ClubGate01_LAx [3749]
3771 CEhillhse14_alpha [3771]
3850 carshowbann_SFSX [3850]
4099 twintjailfence_LAn [4099]
4100 meshfence1_LAn [4100]
4190 SDfences1_LAn [4190]
4195 SDfences2_LAn [4195]
4196 SDfences3_LAn [4196]
4201 SDfences4_LAn [4201]
4202 SDfences5_LAn [4202]
4724 librarywall_lan2 [4724]
5001 lasrunwall2_LAS [5001]
5005 lasrunwall1_LAS [5005]
5007 lasrunwall3_LAS [5007]
5030 lasrunwall1ct_LAS [5030]
5062 hillpawfnce_LAs [5062]
5070 sjmctfnce1_las [5070]
5071 sjmctfnce2_las [5071]
5072 sjmctfnce3_las [5072]
5073 sjmctfnce4_las [5073]
5074 sjmctfnce5_las [5074]
5075 sjmctfnce6_las [5075]
5076 sjmctfnce7_las [5076]
5077 sjmctfnce8_las [5077]
5051 airobarsjm_LAS [5051]
5068 airctsjm1_las [5068]
5081 rdcrashbar1_LAs [5081]
5082 rdcrashbar2_LAs [5082]
5190 scrapfnce_las2 [5190]
5306 chemfence_las2 [5306]
5338 Beach1fnce_las2 [5338]
5893 hblues01Tr_LAwN [5893]
6049 beachwall_law [6049]
6960 vegasNbball2 [6960]
6961 vgsNwedchap3 [6961]
6967 vgnsqrefnce1 [6967]
6968 vgnsqrefnce2 [6968]
6969 vgnsqrefnce3 [6969]
6970 vgsNbnkmsh [6970]
7022 vegasNnewfence2 [7022]
7026 vegnewhousewal05 [7026]
7028 vegnewhousewal01 [7028]
7029 vegnewhousewal02 [7029]
7030 vegnewhousewal03 [7030]
7031 vegnewhousewal04 [7031]
7033 vgnhsegate02 [7033]
7034 vgnhsewall04 [7034]
7038 vegasplantwal1 [7038]
7039 vegasplantwal02 [7039]
7191 vegasNnewfence2b [7191]
7192 vegasNnewfence2c [7192]
7196 vgnNtrainfence01 [7196]
7197 vgnNtrainfence02 [7197]
7198 vgnNtrainfence03 [7198]
7209 vgnNtrainfence04 [7209]
7210 vgnNtrainfence05 [7210]
7212 vgnlowwall03_al [7212]
7223 vgnlowbuild01fnc [7223]
7224 vgnhseing68fnc [7224]
7227 stripshopn1fnc [7227]
7277 vgnlowbuild239_al [7277]
7292 vgsn_mallwall [7292]
7319 vgnlowbuild12a [7319]
7361 casinoblock4al [7361]
7367 vgsNelec_fence_01 [7367]
7368 vgsNelec_fence_05 [7368]
7369 vgsNelec_fence_04 [7369]
7370 vgsNelec_fence_03 [7370]
7371 vgsNelec_fence_02 [7371]
7377 vgsNelec_fence_04a [7377]
7378 vgsNelec_fence_03a [7378]
7379 vgsNelec_fence_02a [7379]
7380 vgsNelec_fence_01a [7380]
7381 vgsNelec_fence_05a [7381]
7418 ballparkbarrier [7418]
7423 glfcrsgate1_vgs [7423]
7504 glfcrsgate2_vgn [7504]
7505 glfcrsgate3_vgn [7505]
7514 vgnwrewall1 [7514]
7517 vgnwreland1 [7517]
7518 vgnhseing82 [7518]
7522 vgnhsegate1 [7522]
7524 vgnhsewall3 [7524]
7538 newaprtmntsvgN16 [7538]
7539 burgerland1 [7539]
7540 burgerland02 [7540]
7556 bballcpark2 [7556]
7560 vgnfrsttfence [7560]
7592 miragebuild11 [7592]
7593 miragebuild12 [7593]
7611 vegasstadwall01 [7611]
7612 vegasstadwall05 [7612]
7613 vegasstadwall04 [7613]
7614 vegasstadwall03 [7614]
7615 vegasstadwall02 [7615]
7623 vegaswtrainfence06 [7623]
7624 vegaswtrainfence07 [7624]
7625 vgnhseing129 [7625]
7657 plasticsgate1 [7657]
7663 vgncarshow2 [7663]
7664 glfcrsgate5_vgs [7664]
7665 glfcrsgate4_vgs [7665]
7692 vgnhseing8282 [7692]
7837 vegaswtrainfence08 [7837]
7838 vegaswtrainfence01 [7838]
7839 vegaswtrainfence02 [7839]
7840 vegaswtrainfence03 [7840]
7841 vegaswtrainfence04 [7841]
7842 vegaswtrainfence05 [7842]
7893 vegascrashbar04 [7893]
7894 vegascrashbar05 [7894]
7919 downvgnbild12 [7919]
7920 vgwstnewall6903 [7920]
7921 vgwstnewall6904 [7921]
7922 vgwstnewall6905 [7922]
7923 vgwstnewall6902 [7923]
7924 vgwstnewall6901 [7924]
7933 vegascrashbar06 [7933]
7939 glfcrsgate29_vgn [7939]
7956 vgwcuntwall1 [7956]
8041 apbarriergate06_lvS [8041]
8042 apbarriergate07_lvS [8042]
8147 vgsSelecfence01 [8147]
8148 vgsSelecfence02 [8148]
8149 vgsSelecfence03 [8149]
8150 vgsSelecfence04 [8150]
8151 vgsSelecfence05 [8151]
8152 vgsSelecfence06 [8152]
8153 vgsSelecfence07 [8153]
8154 vgsSelecfence08 [8154]
8155 vgsSelecfence09 [8155]
8165 vgsSelecfence10 [8165]
8167 apgate1_VegS01 [8167]
8173 vgs_concwall01 [8173]
8174 vgs_concwall02 [8174]
8175 vgs_concwall03 [8175]
8176 vgs_concwall04 [8176]
8177 vgs_concwall05 [8177]
8178 vgs_concwall06 [8178]
8185 vgsSredbrix02 [8185]
8186 vgsSredbrix03 [8186]
8187 vgsSredbrix04 [8187]
8188 vgsSredbrix05 [8188]
8189 vgsSredbrix06 [8189]
8194 vgsScorrag_fence01 [8194]
8206 vgsSstadrail03 [8206]
8207 vgsSstadrail05 [8207]
8208 vgsSstadrail06 [8208]
8209 vgsSelecfence11 [8209]
8210 vgsSelecfence12 [8210]
8229 vgSbikeschl02 [8229]
8262 vgsSelecfence13 [8262]
8263 vgsSelecfence14 [8263]
8311 vgsSelecfence15 [8311]
8313 vgsSelecfence16 [8313]
8314 vgsSelecfence17 [8314]
8315 vgsSelecfence18 [8315]
8320 vegstadrail69 [8320]
8342 vgsSelecfence119 [8342]
8369 vgsSelecfence05b [8369]
8416 bballcourt02_lvs [8416]
8481 csrsfence01_lvs [8481]
8549 fctryfnce01_lvs [8549]
8556 vgshsegate04 [8556]
8559 vgshsewall06 [8559]
8645 shbbyhswall01_lvs [8645]
8646 shbbyhswall02_lvs [8646]
8647 shbbyhswall03_lvs [8647]
8648 shbbyhswall04_lvs [8648]
8649 shbbyhswall05_lvs [8649]
8650 shbbyhswall06_lvs [8650]
8651 shbbyhswall07_lvs [8651]
8652 shbbyhswall12_lvs [8652]
8653 shbbyhswall08_lvs [8653]
8656 shbbyhswall09_lvs [8656]
8657 shbbyhswall10_lvs [8657]
8658 shabbyhouse11_lvs [8658]
8659 shbbyhswall11_lvs [8659]
8662 nucrprkwall_lvs [8662]
8673 csrsfence03_lvs [8673]
8674 csrsfence02_lvs [8674]
8680 chnatwnfnc02_lvs [8680]
8681 chnatwnfnc03_lvs [8681]
8682 chnatwnfnc04_lvs [8682]
8683 chnatwnfnc05_lvs [8683]
8684 chnatwnfnc06_lvs [8684]
8685 chnatwnfnc07_lvs [8685]
8686 chnatwnfnc01_lvs [8686]
8869 vgsEcnstrct05 [8869]
8871 vgsEcnstrct04 [8871]
9029 vgsEtrainfence01 [9029]
9030 vgsEtrainfence02 [9030]
9031 vgsEtrainfence03 [9031]
9032 vgsEtrainfence04 [9032]
9033 vgsEtrainfence05 [9033]
9041 prthotelfnc01 [9041]
9292 sfn_crashbar06 [9292]
9293 sfn_crashbar01 [9293]
9294 sfn_crashbar02 [9294]
9295 sfn_crashbar03 [9295]
9296 sfn_crashbar04 [9296]
9297 sfn_crashbar05 [9297]
9298 sfn_crashbar07 [9298]
9330 SFN_wall_cm01 [9330]
9332 SFN_wall_cm02 [9332]
9337 SFN_WALL_cm2 [9337]
9339 SFNvilla001_CM [9339]
9340 SFNfence_CM01 [9340]
9343 SFN_fence_cm2 [9343]
9349 SFNfence_pres_5 [9349]
9482 chinagate [9482]
9608 ggate_park_sfw [9608]
9893 gardsfw02 [9893]
10252 china_town_gateb [10252]
10396 hc_tenfence_SFS [10396]
10402 hc_secfence_SFS [10402]
10437 hashfence_09_SFS [10437]
10442 graveyardwall_SFS [10442]
10611 fedmintfence_SFS [10611]
10682 shitfence1_SFS [10682]
10683 shitfence2_SFS [10683]
10806 airfence_01_SFSe [10806]
10807 airfence_04_SFSe [10807]
10808 airfence_03_SFSe [10808]
10809 airfence_02_SFSe [10809]
10835 navyfence2_SFSe [10835]
10836 apinnerfence3_SFSe [10836]
10874 apinnerfence1_SFSe [10874]
10875 apinnerfence2_SFSe [10875]
10885 navyfence_SFSe [10885]
10889 dockbarrier1_SFSe [10889]
10890 dockbarrier2_SFSe [10890]
11014 drivingschlgrg_SFS [11014]
11091 crackfactfence_SFS [11091]
11238 dockbarrier2z_SFSe [11238]
11239 dockbarrier2zb_SFSe [11239]
11240 dockbarrier2zc_SFSe [11240]
11241 dockbarrier2zd_SFSe [11241]
11242 dockbarrier2ze_SFSe [11242]
11243 wall_cm_firehse [11243]
11247 TREEBIT21 [11247]
11438 des_indtpfenc [11438]
11452 des_nwshfenc [11452]
11473 des_swtfence1 [11473]
11474 des_swtfence2 [11474]
11499 des_dinerfenc01 [11499]
11551 cn_tunlbarrier [11551]
11567 des_rvstuff [11567]
11568 des_clifftwal [11568]
11571 sw_teline_05 [11571]
11607 sw_teline_06 [11607]
11623 n_dambarriers [11623]
12848 coe_sprunlkfenc [12848]
12858 sw_gate1 [12858]
12933 sw_breweryFence01 [12933]
13016 sw_block04COL27 [13016]
13018 CEmulwire03 [13018]
13024 sw_breweryFence02 [13024]
13045 cunte_roads30bar02 [13045]
13096 cunte_roadsbar01 [13096]
13097 cunte_roads30bar06 [13097]
13098 cunte_roadsbar05 [13098]
13118 cunte_roadsbar02 [13118]
13153 cunte_roads30bar03 [13153]
13336 cunte_roads46walls [13336]
13438 sw_church01fnce [13438]
13445 cunteroads05aFNCE [13445]
13663 dirtfences [13663]
13665 dirtfences2 [13665]
13705 CEhillbar2b [13705]
14464 gs_cages [14464]
14459 carter-cage [14459]
14843 int_policeA01 [14843]
14856 cellsa [14856]
14883 prison-gates [14883]
16016 des_roadbar01 [16016]
16017 des_roadbar02 [16017]
16018 des_roadbar03 [16018]
16019 des_roadbar04 [16019]
16020 des_roadbar05 [16020]
16022 des_geywall1 [16022]
16052 des_ghotfence [16052]
16094 des_a51infenc [16094]
16136 des_telefenc [16136]
16281 des_fgateway01 [16281]
16293 a51_extfence03 [16293]
16294 a51_extfence06 [16294]
16295 quarry_fenc01 [16295]
16296 quarry_fenc04 [16296]
16297 quarry_fenc06 [16297]
16298 quarry_fenc05 [16298]
16299 quarry_fenc02 [16299]
16300 quarry_fenc03 [16300]
16312 quarry_walllthing [16312]
16313 quarry_fencins [16313]
16315 quarry_fencins2 [16315]
16320 quarry_fenc07 [16320]
16321 quarry_fenc08 [16321]
16324 des_quaoldfenc [16324]
16369 des_quaoldfenc01 [16369]
16370 by_fuelfence [16370]
16627 des_ghotfenc01 [16627]
16628 des_ghotfenc02 [16628]
16629 des_ghotfenc03 [16629]
16630 des_ghotfenc04 [16630]
16631 des_ghotfenc05 [16631]
16632 des_ghotfenc06 [16632]
16633 des_ghotfenc07 [16633]
16634 des_ghotfenc08 [16634]
16635 des_ghotfenc09 [16635]
16636 des_ghotfenc10 [16636]
16638 a51_gatecon_a [16638]
16664 a51_jetpalpha [16664]
16668 a51_extfence04 [16668]
16669 a51_extfence05 [16669]
16670 a51_extfence02 [16670]
16671 a51_extfence01 [16671]
16683 cn2_alphabit01 [16683]
17510 barrioTrans01_LAe [17510]
18074 Donut_rail [18074]
18202 wtown_trailwal [18202]
18216 mtbfence1 [18216]
18218 mtbfence08 [18218]
18219 mtbfence09 [18219]
18220 mtbfence10 [18220]
18221 mtbfence11 [18221]
18222 mtbfence12 [18222]
18223 mtbfence14 [18223]
18224 mtbfence15 [18224]
18255 cuntwjunk11 [18255]
18276 mtb2_barrier1 [18276]
18277 mtb2_barrier2 [18277]
18278 mtb2_barrier3 [18278]
18279 mtb2_barrier6 [18279]
18280 mtb2_barrier4 [18280]
18281 mtb2_barrier5 [18281]
18286 cw_mountbarr06 [18286]
18287 cw_mountbarr01 [18287]
18288 cw_mountbarr02 [18288]
18289 cw_mountbarr03 [18289]
18290 cw_mountbarr04 [18290]
18291 cw_mountbarr07 [18291]
18292 cw_mountbarr05 [18292]
18432 mtbfence17 [18432]
18433 mtbfence21 [18433]
18434 mtbfence24 [18434]
18440 mtbfence26 [18440]
18441 mtbfence29 [18441]
18442 mtbfence31 [18442]
18443 mtbfence32 [18443]
18444 mtbfence39 [18444]
18445 mtbfence40 [18445]
18446 mtbfence43 [18446]
Reply
#91

Thanks guys,
But I allready found that list.

Do you know any ID of a small gate that fits inside the LSPD? or door or something.

Thanks.
Reply
#92

http://grandtheftauto.filefront.com/..._Andreas;52116
try this, maybe you find id you need!
Reply
#93

2929-door
11327-wall
11438-wall2
1411-breakable fence
980-fence
971-fence
Reply
#94

I know that epty preprocessor directive (#) converts a string passed as argument of inline function or macros to identifier, but how to make a string using identifier?! I hope i explained clearly....
Reply
#95

maybe %i using format? not sure tho
Reply
#96

Quote:
Originally Posted by ZeeX
I know that epty preprocessor directive (#) converts a string passed as argument of inline function or macros to identifier, but how to make a string using identifier?! I hope i explained clearly....
No, explain better, give an example
Reply
#97

Quote:
Originally Posted by LienK
I have defined 100 colors like this:

#define COLOR_1 0xAAAAAAFF
#define COLOR_2 0xAAAAAAFF
...
#define COLOR_100 0xAAAAAAFF

And I want the player to be able to write /color [number] and then get the color that the number is associated with in the #defines.
Of course I could use:
if(number == 1) { SetPlayerColor(playerid, COLOR_1); }
if(number == 2 { SetPlayerColor(playerid, COLOR_2); }
Etc.

But is there a simpler way to do this? Like taking the number the player inputs and set it at the end of COLOR_, or something?
Try something like
pawn Код:
format(string, 20, "COLOR_%d", number);
SetPlayerColor(playerid, string);
But that will probably bring a tag mismatch error. You could try a IntToHex function or something
Reply
#98

Quote:
Originally Posted by LienK
I have defined 100 colors like this:

#define COLOR_1 0xAAAAAAFF
#define COLOR_2 0xAAAAAAFF
...
#define COLOR_100 0xAAAAAAFF

And I want the player to be able to write /color [number] and then get the color that the number is associated with in the #defines.
Of course I could use:
if(number == 1) { SetPlayerColor(playerid, COLOR_1); }
if(number == 2 { SetPlayerColor(playerid, COLOR_2); }
Etc.

But is there a simpler way to do this? Like taking the number the player inputs and set it at the end of COLOR_, or something?
No, that isn't possible.

But I believe this is possible:
pawn Код:
new color[] =
{
  0xFFFFFF,
  0xFFFF00,
  0xFF00FF,
  0x00FFFF,
  0x0000FF,
  0x00FF00
};

// @ /color [number]
SetPlayerColor(playerid, color[number]);
Reply
#99

I have a question about which is faster and such. Suppose you were using an enumeration for example or just an array for that matter and you needed a certain one from the enum multiple times in one function. Like this.

pawn Код:
GetVehiclePos(PlayerInformation[playerid][LastVehicleID],x,y,z);
SetPlayerPos(i,x,y,z);
SetVehicleHealth(PlayerInformation[playerid][LastVehicleID],0);
DestroyVehicle(PlayerInformation[playerid][LastVehicleID]);
That's just an example. What I was wondering is if it would be faster to just do this.

pawn Код:
new veh = PlayerInformation[playerid][LastVehicleID];
GetVehiclePos(veh,x,y,z);
SetPlayerPos(i,x,y,z);
SetVehicleHealth(veh,0);
DestroyVehicle(veh);
I just thought maybe it would be easier for it to look up that variable once and just use it locally in whatever function instead of looking it up multiple times. But since I don't know how the computer processes this information or in what order it does it, I was just asking.
Reply

Quote:
Originally Posted by Y_Leѕѕ
Well it seems the part I'm interested in is here.

Quote:

Where the line starts getting blurry is with repeated calls. For example, which of these is faster:

pawn Код:
new var = gArr[10];
printf("%d %d", var, var);
pawn Код:
printf("%d %d", gArr[10], gArr[10]);
The first one has one array access, one variable write and two variable reads, the second has two array accesses. Truthfully I'm not sure which is faster but I have a general rule:

More than one function call - save it in a variable, more than two array reads save it in a variable, so for the above code I would probably use the second version...

Maybe I will run one of those scripts to test the speed and see. Thanks.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)