[Plugin] Pawn.CMD

Quote:
Originally Posted by IstuntmanI
Посмотреть сообщение
pawn Код:
format( cmd, 32, "/stunt%d", stuntID );
PC_EmulateCommand( playerid, cmd ); // recommended, as it is handled as a regular command
or
pawn Код:
format( cmd, 32, "pc_cmd_stunt%d", stuntID );
CallLocalFunction( cmd, "s", "\0" );
I'll give it a try, thx.

OFF: Multumesc batrane, stiu ca tot nu ma suporti )
Reply

Pawn.CMD.inc(60) : error 025: function heading differs from prototype?
Reply

Quote:
Originally Posted by Clivlend
Посмотреть сообщение
Pawn.CMD.inc(60) : error 025: function heading differs from prototype?
Remove ZCMD (or whatever other CMD processor you have) and change the callbacks' parameters to match the ones in this plugin's include (seen on the main thread post).
Reply

Your plugin is amazing. Congratulations.

*removed*
Reply

Quote:
Originally Posted by IstuntmanI
Посмотреть сообщение
pawn Код:
format( cmd, 32, "/stunt%d", stuntID );
PC_EmulateCommand( playerid, cmd ); // recommended, as it is handled as a regular command
or
pawn Код:
format( cmd, 32, "pc_cmd_stunt%d", stuntID );
CallLocalFunction( cmd, "s", "\0" );
Well for me is not work

new cmd[32];
format( cmd, 32, "pc_cmd_setinterior%d%d", 0,5 );
CallLocalFunction( cmd, "s", "\0" );

my server is crashed

Код HTML:
[00:45:19] [debug] Server crashed while executing rpg.amx
[00:45:19] [debug] AMX backtrace:
[00:45:19] [debug] #0 native CallLocalFunction () from samp-server.exe
[00:45:19] [debug] #1 000632c0 in public OnDialogResponse (0, 30, 1, 2, 9299988) from rpg.amx
[00:45:19] [debug] Native backtrace:
[00:45:19] [debug] #0 0047467c in ?? () from samp-server.exe
[00:45:19] [debug] #1 004010b6 in ?? () from samp-server.exe
[00:45:19] [debug] #2 745462ca in AmxCallback () from plugins\crashdetect.DLL
[00:45:19] [debug] #3 74548b28 in amx_Exec () from plugins\crashdetect.DLL
[00:45:19] [debug] #4 745409c7 in CrashDetect::DoAmxExec () from plugins\crashdetect.DLL
[00:45:19] [debug] #5 7454631a in AmxExec () from plugins\crashdetect.DLL
[00:45:19] [debug] #6 744d51b9 in ?? () from plugins\streamer.DLL
[00:45:19] [debug] #7 0046ec31 in ?? () from samp-server.exe
[00:45:19] [debug] #8 00452270 in ?? () from samp-server.exe
[00:45:19] [debug] #9 0049eef9 in ?? () from samp-server.exe
[00:45:19] [debug] #10 004aa31e in ?? () from samp-server.exe
I used on a case from a dialog, did exist and other metod to call a command wiht parameters?
Reply

Just use PC_EmulateCommand() ffs. It's there for a reason.
Reply

Mister0 you can't send NULL in CallLocalFunction "s", "\0" ); ;d read wiki about this, just use
pawn Код:
pc_cmd_setinterior(playerid, "0 5");
or

pawn Код:
callcmd::setinterior(playerid, "0 5");
Reply

Can I use this?
Код:
pc_cmd_setinterior(playerid, "0 PlayerInfo [playerid][pInterior]"); ?
Reply

Quote:
Originally Posted by Jefff
Посмотреть сообщение
Mister0 you can't send NULL in CallLocalFunction "s", "\0" ); ;d read wiki about this, just use
pawn Код:
pc_cmd_setinterior(playerid, "0 5");
or

pawn Код:
callcmd::setinterior(playerid, "0 5");
Aw, my bad. Probably \1\0 is ok if "params" isn't required.

Quote:
Originally Posted by Mister0
Посмотреть сообщение
Can I use this?
Код:
pc_cmd_setinterior(playerid, "0 PlayerInfo [playerid][pInterior]"); ?
Try
Код:
format( string, 8, "0 %d", PlayerInfo[ playerid ][ pInterior ] );
pc_cmd_setinterior( playerid, string );
Reply

All of you are just wrong. There are functions and macros made for exactly what you want.

The callcmd macro and the PC_EmulateCommand function are both for calling commands like this. Don't call the function manually, that's not how the plugin was made to be treated.
Reply

Quote:
Originally Posted by Crayder
Посмотреть сообщение
All of you are just wrong. There are functions and macros made for exactly what you want.

The callcmd macro and the PC_EmulateCommand function are both for calling commands like this. Don't call the function manually, that's not how the plugin was made to be treated.
Actually, I told him that PC_EmulateCommand is recommended.

By the way, "callcmd::" macro is the same thing as "pc_cmd_" (excepting the fact that it won't be automatically replaced with the help of include, if the command function will be renamed [anyway, the function name won't be renamed, as there's no need to anymore]):
pawn Код:
#define callcmd::%0(%1) pc_cmd_%0(%1)
I preffer to use "pc_cmd_" because of one thing: "callcmd::" can't be used in things like CallRemote/LocalFunction as (a regular public name, a string), as it is just a replacement for the compiler.

And anyway, manually calling the function has two more benefits (of which I can think now): first, we can increase the execution speed, as it isn't calling those 2 callbacks, and second, we can also execute that command's function even if there's a flag/OnPlayerCommandReceive rule which prohibits it.
Reply

PC_EmulateCommand is the only actual way to do it then. It's the only one that actually calls the legit command. It's the only one that will take all of this plugin's features into consideration.

Like Y_Less always said about this with YCMD, if a commands features are meant to be called anywhere other than the command then those features should be in a function of their own. Call that separate function from the command. There should be absolutely no need AT ALL to call a command callback manually.

Also, I thought callcmd was a macro for PC_EmulateCommand.
Reply

Great job man,this plugin works like a charm.
Reply

Quote:
Originally Posted by Crayder
Посмотреть сообщение
PC_EmulateCommand is the only actual way to do it then. It's the only one that actually calls the legit command. It's the only one that will take all of this plugin's features into consideration.

Like Y_Less always said about this with YCMD, if a commands features are meant to be called anywhere other than the command then those features should be in a function of their own. Call that separate function from the command. There should be absolutely no need AT ALL to call a command callback manually.

Also, I thought callcmd was a macro for PC_EmulateCommand.
tbh there is no such thing called "CMD" to pawn, it's just a word/string of characters we use to call up a set of procedures, code-wise all these cmds are just merely a public function that get called by the command processor, so we are technically still doing what Y_Less said.

Both ways are the "right way" to call commands, he just gave a bad syntax for the CallRemoteFunction, as empty strings crash server.

PHP код:
CallLocalFunctioncmd"ds"playerid"\1\0" ); 
idk how people tend to forget the poor playerid param xD it doesn't get magically added.
Reply

Quote:
Originally Posted by PrO.GameR
Посмотреть сообщение
tbh there is no such thing called "CMD" to pawn, it's just a word/string of characters we use to call up a set of procedures, code-wise all these cmds are just merely a public function that get called by the command processor, so we are technically still doing what Y_Less said.

Both ways are the "right way" to call commands, he just gave a bad syntax for the CallRemoteFunction, as empty strings crash server.
Once again, you are skipping the entire concept and abusing the point of a command processor. Calling the callbacks manually is not "calling a command", it's calling a callback. None of the processor's features are being handled.
Reply

Quote:
Originally Posted by Crayder
Посмотреть сообщение
Once again, you are skipping the entire concept and abusing the point of a command processor. Calling the callbacks manually is not "calling a command", it's calling a callback. None of the processor's features are being handled.
I guess I chose my words wrong, but thats exactly the point, why would anyone need to simulate a command as part of another procedure? commands are designed to establish a connection between player and server and start a set of tasks, giving the player choice of calling said connection and tasks whenever he wants, why would the server put itself back as a middleman again when it can directly establish a connection? (Yes in some cases it is necessary, something like flag checks and those, but why would anyone for example emulate the /enter command instead of directly using the callback, having that go thru command processor is unnecessary)
Reply

Quote:
Originally Posted by Dodo9655
Посмотреть сообщение
Thank you for your reply. I have decided to use your 22 flags defines you posted earlier in this topic.

But I need help with adjusting my conditional statements in OnPlayerCommandReceived(), because in their present state permissions are still not working properly. Could you provinde an example?

Thanks!
If you don't know much about bit manipulation I suggest opening a thread about this in the Scripting Help section on this subject.
Reply

Quote:
Originally Posted by Crayder
Посмотреть сообщение
If you don't know much about bit manipulation I suggest opening a thread about this in the Scripting Help section on this subject.
I'd rather ask here than make a whole new topic because I've looked into the matter now and got a little question:

Why use (flags & DEFINED_FLAG) ? Wouldn't (flags == DEFINED_FLAG) make more sense?

I figured out that option 2 wouldn't work if you used multiple flags for one command.

But as far as I'm concerned doesn't the & operation make a bitstring?
Won't that bitstring be interpreted as an integer when using the && operator?

Edit: I actually figured it out while typing this message, lol. Thanks a bunch!
Reply

Quote:
Originally Posted by Dodo9655
Посмотреть сообщение
I'd rather ask here than make a whole new topic because I've looked into the matter now and got a little question:

Why use (flags & DEFINED_FLAG) ? Wouldn't (flags == DEFINED_FLAG) make more sense?

I figured out that option 2 wouldn't work if you used multiple flags for one command.

But as far as I'm concerned doesn't the & operation make a bitstring?
Won't that bitstring be interpreted as an integer when using the && operator?

Edit: I actually figured it out while typing this message, lol. Thanks a bunch!
This is precisely why I suggested you should open a Scripting Help thread. You don't understand the bit manipulation. That's an issue not relative to this plugin or it's features, and thus not relative to this thread so stop spamming it.
Reply

How to use function PC_GetCommandName? How to get command index?
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)