Oldskool
#21

A macro would be a nice easy way of doing it too, now my system has evolved into a YAML type file loaded and category based system.

Now it looks like this and is really easy to edit either the file or in game with some dev commands:
Код:
category:Places
{
//	cmd	name		coordinates					angle	freeze

	ls,	Los Santos,	1186.8282,	-1324.1444,	13.5591,	0.0,	0
	sf,	San Fierro,	-1986.2489,	288.5100,	34.2673,	0.0,	0
	lv,	Las Venturas,	2032.2878,	1342.8140,	10.8203,	0.0,	0
}
Also the loop for this is performed after the regular CallLocalFunction commands, I think that makes more sense as it's more likely to be another command than a teleport (there are only around 50 teleports, but more commands)
Reply
#22

Quote:
Originally Posted by AndreT
Посмотреть сообщение
And if you want to dynamically (dis)allow the usage of the command, use an array.
Or just y_commands...
Reply
#23

Quote:
Originally Posted by Y_Less
Посмотреть сообщение
Or just y_commands...
or even y_bit... or y_playerarray... and if you really don't want to use anything pre-made because ur so oldsk00l l33t you simply use bit shifting!

pawn Код:
new n = n << 1
new y = n >> 1
And if that's too complicated for you, here is an even easier way!

pawn Код:
#define COMMAND_CUFF 1
#define COMMAND_TAZER 2
#define COMMAND_SLAP 4
#define COMMAND_COUGH 8 // notice how each is double of the last?

// in order to assign:

new PlayerPermission = COMMAND_CUFF + COMMAND_SLAP + COMMAND_COUGH; // player can not use TAZER

// In order to check

if(!(COMMAND_TAZER&PlayerPermission))
{
     // sry cant use!
}
Isn't that hard.. now is it?

PS: That's pretty much what y_commands does already but you know how oldsk00l people are! They have to have made it themself.
Reply
#24

You'll only be able to set up permissions for 32 commands with that code.
Reply
#25

Quote:
Originally Posted by Extremo
Посмотреть сообщение
pawn Код:
#define COMMAND_CUFF 1
#define COMMAND_TAZER 2
#define COMMAND_SLAP 4
#define COMMAND_COUGH 8 // notice how each is double of the last?
For reference:

PHP код:
enum (<<= 1)
{
    
COMMAND_CUFF 1,
    
COMMAND_TAZER,
    
COMMAND_SLAP,
    
COMMAND_COUGH

Much simpler way of doing bit masks (means you can add and remove them very quickly), but Slice is right (though to be fair you did mention y_bits).
Reply
#26

Well, if you understand bit-shifting you'd obviously have to have understanding of how many bits a variable in pawn has in the first place!
Reply
#27

Three trusty words: Zcmd and SQLite.
Reply
#28

What the hell is wrong with you people still posting on this 4 month old thread..
I quited sa-mp already -.-" so uhhm anyway..
Let's just proceed this thread with the main question:
What are your favorite ways of scripting?
Reply
#29

Better than creating new topics all the time!
Reply
#30

Yes I agree, that's why I decided to re-open this thread..

Come on guys, just share your favorite ways of scripting
Reply
#31

My favourite way is the way that gets the job done!

Also, recently I've been writing code as if it was for someone else, always making things flexible. For instance I've made all my recent minigame scripts almost completely stand-alone (the only dependency is the player's current minigame ID which is declared in the master script, it's used to enter/exit the game or restrict certain freeroam commands)

I do this mainly so if someone requests it, I can just post it and it should be easy to "install" onto their gamemode, the only errors should just be "undefined symbol" for the things that belong to my main script (current minigame, admin level etc) things that should be easy to substitute.

Another thing is, static globals! I have recently copied a minigame code as I designed another game that was very similar, the issue was, I forgot to substitute some of the function/variable name prefixes so one script was editing or reading values from another! Static variables eliminate this as they aren't recognised outside of the include they are created in.


I have mainly been "copying" the way Object Oriented languages like Java with the Public/Private variables or functions and having "Interface" functions for altering variables from scripts (Even if it's just to do something simple like set it's value).
Reply
#32

Yep, your way of making your minigame scripts is what I do with all bigger scripts, like a business/house system or job/faction system, car system etc, all stand-alone.
Reply
#33

i still use old file functions :d (etc fwrite and fread)

but zcmd with mysql usually
Reply
#34

My favorite way it's make the script with logic.

Most of the case i use MySQL because it is easy to use it, is fast, has more space available, and you can connect MySQL with other Programing Languages.

For the command processor, i use my own
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)