SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 14/09/2017, 02:25 PM   #1
Peveral
Little Clucker
 
Join Date: Jul 2016
Posts: 16
Reputation: 0
Question Return CMD

Hello,So i have this code:
PHP Code:
    if(strcmp(cmd"/enter"true) == 0)
    {
Bla bla bla

I wanna return this cmd "/enter" somewhere else.
Any idea how to return it?
I cant use "return cmd_enter(playerid, params);" cuz im not using zcmd.
If there is anyways to return it or any other ways,I would like to learn.
Peveral is offline   Reply With Quote
Old 14/09/2017, 02:32 PM   #2
Vince
Spam Machine
 
Vince's Avatar
 
Join Date: Sep 2007
Location: Belgium
Posts: 10,083
Reputation: 2655
Default Re: Return CMD

You put all the contents of that command in a separate function and then you call that function from wherever you want. Return cmd_ is, IMO, a poor design choice.
__________________
Vince is offline   Reply With Quote
Old 14/09/2017, 02:36 PM   #3
Zeth
Huge Clucker
 
Zeth's Avatar
 
Join Date: Feb 2017
Location: Titan
Posts: 428
Reputation: 114
Default Re: Return CMD

you can make a function then run that program on that cmd and as on other function like what Vince said. Here is a example:
PHP Code:

forward returncommand
(playerid);
public 
returncommand(playerid)
{

Bla bla bla //content


return 1//return the function

then you can use it wherever you want.
PHP Code:


if(strcmp(cmd"/enter"true) == 0

      
returncommand(playerid); 

Zeth is offline   Reply With Quote
Old 14/09/2017, 03:05 PM   #4
Peveral
Little Clucker
 
Join Date: Jul 2016
Posts: 16
Reputation: 0
Default Re: Return CMD

hmm Thanks,Where should i make functions?Can i just make them anywhere or there is any place for them?
Peveral is offline   Reply With Quote
Old 14/09/2017, 03:08 PM   #5
Zeth
Huge Clucker
 
Zeth's Avatar
 
Join Date: Feb 2017
Location: Titan
Posts: 428
Reputation: 114
Default Re: Return CMD

Quote:
Originally Posted by Peveral View Post
hmm Thanks,Where should i make functions?Can i just make them anywhere or there is any place for them?
Yeah you can place them anywhere, there is no problem.
Zeth is offline   Reply With Quote
Old 14/09/2017, 03:18 PM   #6
Peveral
Little Clucker
 
Join Date: Jul 2016
Posts: 16
Reputation: 0
Default Re: Return CMD

Well there are errors,
undefined symbol "returncommand"
I defined it already but idk why
Peveral is offline   Reply With Quote
Old 14/09/2017, 03:20 PM   #7
Zeth
Huge Clucker
 
Zeth's Avatar
 
Join Date: Feb 2017
Location: Titan
Posts: 428
Reputation: 114
Default Re: Return CMD

did u made forward and public of returncommand?
Zeth is offline   Reply With Quote
Old 14/09/2017, 03:23 PM   #8
Peveral
Little Clucker
 
Join Date: Jul 2016
Posts: 16
Reputation: 0
Default Re: Return CMD

Yes,Just like you said
Peveral is offline   Reply With Quote
Old 14/09/2017, 03:32 PM   #9
Peveral
Little Clucker
 
Join Date: Jul 2016
Posts: 16
Reputation: 0
Default Re: Return CMD

I have this now
PHP Code:
forward returnenter(playerid);
public 
returnenter(playerid)
{
My Codes
}

    if(
strcmp(cmd"/enter"true) == 0)
    {
            
returnenter(playerid);
    } 
But it will say undefined symbol returnenter
Peveral is offline   Reply With Quote
Old 14/09/2017, 10:00 PM   #10
Peveral
Little Clucker
 
Join Date: Jul 2016
Posts: 16
Reputation: 0
Default Re: Return CMD

so guys any idea
Peveral 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
function should return a value? But i use return.. faxxe Scripting Help 4 21/03/2017 11:08 PM
continue and return 0 and return 1 and break work? MBilal Scripting Help 7 15/05/2016 09:12 AM
How to return a string variable using the multi-return method? Juvanii Scripting Help 7 04/03/2016 10:32 PM
What's the diffrences between Return True and Return False davidstyle1125 Scripting Help 4 09/12/2014 09:34 PM
return true vs return 1 +rep genesis87 Scripting Help 3 02/02/2012 09:24 AM


All times are GMT. The time now is 08:58 AM.


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