SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 08/03/2018, 03:13 PM   #1
Osamakurdi
Big Clucker
 
Join Date: Mar 2017
Location: Syria
Posts: 193
Reputation: 19
Default Is it possible to : ?

Is it possible to add command from game ?
A simple command that send a message only This code:
PHP Code:
CMD:addcommand(playeridparams[])
{
    new 
cmdname[25], textsend[180];
    if(
sscanf(params"s[25]s[180]"cmdnametextsend)) return SendClientMessage(playeridCOLOR_WHITE"USAGE:/addcommand <cmd name> <text that cmd gonna send>");
    return 
1;

For example:
/addcommand <help> <Help isn't available now.>
so cmd help can be added in script and when player type /help it will send him Help isn't available now.
__________________
(( لا تقسروا اولادكم على ادابكم فانهم مخلوقون لزمان غير زمانكم ))

((Do not oppress your children to your literature, they are created for a time other than your time))
Osamakurdi is offline   Reply With Quote
Old 08/03/2018, 03:17 PM   #2
ISmokezU
Gangsta
 
Join Date: Aug 2016
Posts: 542
Reputation: 75
Default Re: Is it possible to : ?

Don’t be lazy. This doesn’t even make sense code them separately.
ISmokezU is offline   Reply With Quote
Old 09/03/2018, 06:53 AM   #3
SeanDenZYR
Big Clucker
 
Join Date: May 2016
Posts: 166
Reputation: 20
Default Re: Is it possible to : ?

try checking this out.
showthread.php?t=608474
SeanDenZYR is offline   Reply With Quote
Old 09/03/2018, 06:59 AM   #4
Sew_Sumi
Banned
 
Join Date: Jun 2008
Location: Azerbaijan
Posts: 6,243
Reputation: 525
Default Re: Is it possible to : ?

This doesn't fit what they are wanting to do...

Seems like an attempt at a dynamic command system, but really, it's flawed in the long run.


Simply do as what ISmokezU said... Simply code the commands, as in the longer term, those commands should be populated later, so you could easily just make...

Code:
CMD:help(playerid) 
{ 
    SendClientMessage(playerid, COLOR_WHITE, "Help will be available soon."); 
    return 1; 
}
Sew_Sumi is offline   Reply With Quote
Old 09/03/2018, 11:06 AM   #5
AroseKhanNiazi
High-roller
 
AroseKhanNiazi's Avatar
 
Join Date: Jan 2014
Location: Pakistan
Posts: 1,349
Reputation: 78
Default Re: Is it possible to : ?

To be honest I don't think it's gonna be possible. If it is that's really gonna be hard and would be limited too.
AroseKhanNiazi is offline   Reply With Quote
Old 09/03/2018, 11:10 AM   #6
KayJ
Gangsta
 
KayJ's Avatar
 
Join Date: Apr 2014
Posts: 678
Reputation: 64
Default Re: Is it possible to : ?

Store them in file and load them with texts?
I saw that in a script in some forums and that command does the same thing but limited to that only.
KayJ is offline   Reply With Quote
Old 09/03/2018, 11:19 AM   #7
Sew_Sumi
Banned
 
Join Date: Jun 2008
Location: Azerbaijan
Posts: 6,243
Reputation: 525
Default Re: Is it possible to : ?

^^ I remember something similar, yet I searched for it thinking it was "Dynamic Commands" but couldn't find it.
Sew_Sumi is offline   Reply With Quote
Old 09/03/2018, 05:29 PM   #8
Meller
Banned
 
Join Date: Dec 2016
Posts: 578
Reputation: 132
Default Re: Is it possible to : ?

This question has very little to none explanation, and those who's said it's impossible slash very hard to, please provide some logic to that? What you're asking to do is create a message response when a client sends the messages which is given in an input. This is very easy in the long run, all you have to do is look at the compability and stability.

The run of this idea is to: register the keyworf '${commandKey}' to a database storage (let it be file storage or MariaDB etc), register another keyword '${commandResponse}'. Then we've got a list of 'commands' defined by a user. Since PAWN is working under the runtime only, we now gotta define this list of commands staticly, to do this you can use the callback of 'OnPlayerCmdText', however. It will depend on how you code this, will you loop over the list of the registered commands, will you pull the data everytime a slash is written, will you use 'if' statements, and so on. All of those examples are bad practice, keep that in mind. I believe this is enough to get you on track.


for the love of god, don't ask me for code.
Meller 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



All times are GMT. The time now is 01:26 PM.


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