[HLF]Southclaw
Unregistered
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)
Posts: 15,941
Threads: 0
Joined: Jun 2008
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...
Posts: 1,831
Threads: 69
Joined: Mar 2008
Reputation:
0
You'll only be able to set up permissions for 32 commands with that code.
Posts: 15,941
Threads: 0
Joined: Jun 2008
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).
Posts: 717
Threads: 11
Joined: Jul 2008
Reputation:
0
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!
Posts: 1,739
Threads: 53
Joined: Oct 2010
Reputation:
0
Three trusty words: Zcmd and SQLite.
Posts: 844
Threads: 32
Joined: Apr 2009
Reputation:
0
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?
Posts: 15,941
Threads: 0
Joined: Jun 2008
Better than creating new topics all the time!
[HLF]Southclaw
Unregistered
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).
Posts: 844
Threads: 32
Joined: Apr 2009
Reputation:
0
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.