SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Plugin Development

Reply
 
Thread Tools Display Modes
Old 07/09/2018, 06:37 PM   #441
Romero837
Big Clucker
 
Romero837's Avatar
 
Join Date: Jul 2016
Posts: 133
Reputation: 1
Default Re: Pawn.CMD

Help @YourShadow
Romero837 is offline   Reply With Quote
Old 10/09/2018, 04:33 AM   #442
Alteh
Little Clucker
 
Alteh's Avatar
 
Join Date: Aug 2018
Posts: 31
Reputation: 3
Default Re: Pawn.CMD

@YourShadow


should give possibility that other symbols can be added ( @, !, &, $, %, ) instead of alone " / "



Example:

Code:
CMD:@at(playerid)
{
    //yourcodeblabla...
    return 1;
}

CMD:/at(playerid)
{
    //yourcodeblabla...
    return 1;
}

CMD:!at(playerid)
{
    //yourcodeblabla...
    return 1;
}

CMD:$at(playerid)
{
    //yourcodeblabla...
    return 1;
}
would print:

Code:
@at | /at | !at | $at
if symbolos is not added then by default it will be "/"

Code:
CMD:pallaringas(playerid)
{
    return 1;
}
I hope you have this suggestion in mind for future updating.
Alteh is offline   Reply With Quote
Old 10/09/2018, 05:04 PM   #443
NaS
High-roller
 
NaS's Avatar
 
Join Date: Mar 2008
Posts: 1,584
Reputation: 466
Default Re: Pawn.CMD

Quote:
Originally Posted by Alteh View Post
@YourShadow


should give possibility that other symbols can be added ( @, !, &, $, %, ) instead of alone " / "



Example:

Code:
CMD:@at(playerid)
{
    //yourcodeblabla...
    return 1;
}

CMD:/at(playerid)
{
    //yourcodeblabla...
    return 1;
}

CMD:!at(playerid)
{
    //yourcodeblabla...
    return 1;
}

CMD:$at(playerid)
{
    //yourcodeblabla...
    return 1;
}
would print:

Code:
@at | /at | !at | $at
if symbolos is not added then by default it will be "/"

Code:
CMD:pallaringas(playerid)
{
    return 1;
}
I hope you have this suggestion in mind for future updating.
Technically not possible that way since these symbols would be part of the function name. Some of these aren't possible to use in function names in PAWN.
NaS is offline   Reply With Quote
Old 10/09/2018, 09:00 PM   #444
Undef1ned
Big Clucker
 
Undef1ned's Avatar
 
Join Date: Aug 2018
Location: Venezuela
Posts: 189
Reputation: 12
Default Re: Pawn.CMD

Quote:
Originally Posted by Alteh View Post
@YourShadow


should give possibility that other symbols can be added ( @, !, &, $, %, ) instead of alone " / "



Example:

Code:
CMD:@at(playerid)
{
    //yourcodeblabla...
    return 1;
}

CMD:/at(playerid)
{
    //yourcodeblabla...
    return 1;
}

CMD:!at(playerid)
{
    //yourcodeblabla...
    return 1;
}

CMD:$at(playerid)
{
    //yourcodeblabla...
    return 1;
}
would print:

Code:
@at | /at | !at | $at
if symbolos is not added then by default it will be "/"

Code:
CMD:pallaringas(playerid)
{
    return 1;
}
I hope you have this suggestion in mind for future updating.
Quote:
Originally Posted by NaS View Post
Technically not possible that way since these symbols would be part of the function name. Some of these aren't possible to use in function names in PAWN.
Exact. Although if you want something like that, you can use "OnPlayerText".

PHP Code:
if(text[0] == '!command' && Player[playerid][Spawned] == 1)
    {
          
//function....
        
return 0;
    } 
It is not recommended to fill the "OnPlayerText" callback with pure commands. It's just a suggestion that if you can do something with that callback.
Undef1ned is offline   Reply With Quote
Old 11/09/2018, 03:27 AM   #445
Alteh
Little Clucker
 
Alteh's Avatar
 
Join Date: Aug 2018
Posts: 31
Reputation: 3
Default Re: Pawn.CMD

why not?

look it:

Code:
public OnPlayerCommandText(playerid, cmdtext[])
{
if(!strcmp(cmdtext, "!cmd", true))
{
    SendClientMessage(playerid, -1, "Message 1");
    return 1;
}
if(!strcmp(cmdtext, "&cmd", true))
{
    SendClientMessage(playerid, -1, "Message 2");
    return 1;
}
if(!strcmp(cmdtext, "@cmd", true))
{
    SendClientMessage(playerid, -1, "Message 3");
    return 1;
}
return 0;
}
If that's possible... Why not with the function of Pawn.CMD?
Alteh is offline   Reply With Quote
Old 11/09/2018, 04:00 AM   #446
DTV
Gangsta
 
DTV's Avatar
 
Join Date: Dec 2010
Posts: 534
Reputation: 121
Default Re: Pawn.CMD

Quote:
Originally Posted by Alteh View Post
why not?

look it:

Code:
public OnPlayerCommandText(playerid, cmdtext[])
{
if(!strcmp(cmdtext, "!cmd", true))
{
    SendClientMessage(playerid, -1, "Message 1");
    return 1;
}
if(!strcmp(cmdtext, "&cmd", true))
{
    SendClientMessage(playerid, -1, "Message 2");
    return 1;
}
if(!strcmp(cmdtext, "@cmd", true))
{
    SendClientMessage(playerid, -1, "Message 3");
    return 1;
}
return 0;
}
If that's possible... Why not with the function of Pawn.CMD?
Taken from the SA-MP Wiki:

Quote:
This callback is called when a player enters a command into the client chat window. Commands are anything that start with a forward slash, e.g. /help.
If I'm not mistaken, commands are only registered as commands by OnPlayerCommandText if it detects the forward slash as the first character. Might be possible to make it different through Pawn.CMD but the code you posted wouldn't work.
__________________
Bringing the nuclear post apocalyptic setting to SA-MP, click the banners to view the forum or Discord server.



DTV is offline   Reply With Quote
Old 11/09/2018, 12:22 PM   #447
NaS
High-roller
 
NaS's Avatar
 
Join Date: Mar 2008
Posts: 1,584
Reputation: 466
Default Re: Pawn.CMD

Quote:
Originally Posted by Alteh View Post
why not?

look it:

Code:
public OnPlayerCommandText(playerid, cmdtext[])
{
if(!strcmp(cmdtext, "!cmd", true))
{
    SendClientMessage(playerid, -1, "Message 1");
    return 1;
}
if(!strcmp(cmdtext, "&cmd", true))
{
    SendClientMessage(playerid, -1, "Message 2");
    return 1;
}
if(!strcmp(cmdtext, "@cmd", true))
{
    SendClientMessage(playerid, -1, "Message 3");
    return 1;
}
return 0;
}
If that's possible... Why not with the function of Pawn.CMD?
Because using strcmp is completely different from ZCMD or PawnCMD.

ZCMD and PawnCMD create a public function for your command to call when the player types it. That's why they are so much faster.
The command you type gets directly called instead of compared to hundreds of strings.

So making a command like this:

Code:
CMD:test(playerid, params[])
{
}
will declare a public function called "cmd_test". Since you can call public functions by name from anywhere (with (eg) CallLocalFunction) this can be done from the command processor as well.

Using symbols would make these part of the function name, which isn't possible as such. Not sure if you could use some tricks to get around it.

Of course you could substitute these symbols with something like a prefix.
You could just as well use ZCMD for it and modify it to use OnPlayerText and replace (eg.) '$' with something else before calling your Command.

I'm not sure if many people need this, so I don't know if it would be worth implementing. But that's not up to me anyway :P
NaS is offline   Reply With Quote
Old 11/09/2018, 01:08 PM   #448
Calisthenics
Huge Clucker
 
Join Date: May 2018
Posts: 340
Reputation: 52
Default Re: Pawn.CMD

Quote:
Originally Posted by Undef1ned View Post
Exact. Although if you want something like that, you can use "OnPlayerText".

PHP Code:
if(text[0] == '!command' && Player[playerid][Spawned] == 1)
    {
          
//function....
        
return 0;
    } 
It is not recommended to fill the "OnPlayerText" callback with pure commands. It's just a suggestion that if you can do something with that callback.
You only need to check the first character: http://forum.sa-mp.com/showpost.php?...&postcount=160
Calisthenics is online now   Reply With Quote
Old 11/09/2018, 10:12 PM   #449
Alteh
Little Clucker
 
Alteh's Avatar
 
Join Date: Aug 2018
Posts: 31
Reputation: 3
Default Re: Pawn.CMD

Quote:
Originally Posted by Calisthenics View Post
You only need to check the first character: http://forum.sa-mp.com/showpost.php?...&postcount=160
Ohh, I did not know.


thanks!
Alteh is offline   Reply With Quote
Old 13/10/2018, 05:00 PM   #450
YenTy
Little Clucker
 
Join Date: Mar 2018
Posts: 20
Reputation: 0
Default Re: Pawn.CMD

Is it possible to add more than one custom file as a #include with different commands? I've issues which prevents me from creating a tree fro dynamic gamemode containing a lot of places with differents parts of it. I mean: I can #include only one file.pwn, any other included after is not working.
YenTy is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Plugin] Vectoral Pawn - STL Data containers for pawn Rancho Plugin Development 70 03/05/2017 07:41 PM
Forum bug with [pawn][/pawn] BBCODE Yuripe Everything and Nothing 4 06/10/2012 12:58 PM
[Tool/Web/Other] PAWN Scanner - Scan PAWN files for information. Slice Tools and Files 10 15/07/2012 07:09 PM
[Help With Pawn] Pawn and compiler is not working..... D_Less Client Support 3 09/03/2012 04:49 AM


All times are GMT. The time now is 07:26 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.