SA-MP Forums Archive
question - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: Other (https://sampforum.blast.hk/forumdisplay.php?fid=7)
+--- Forum: Everything and Nothing (https://sampforum.blast.hk/forumdisplay.php?fid=23)
+--- Thread: question (/showthread.php?tid=651972)



question - Deadpoop - 31.03.2018

why most people code like this

PHP код:
CMD:x(playeridparams[])
{
    new 
targetstr[x];
        
//some code
    
return 1;

when they can code like this

PHP код:
CMD:x(playeridstr[], target)
{
    
//some code
    
return 1;




Re: question - Kaperstone - 31.03.2018

because you don't always target a player and param are really just parameters.
it is a lot better that way because using this and sscanf you can have many parameters of different types in unordered way.
/command [string] [int] [char] [float]
/command [float] [string] [int]

etc.

sscanf just slices your string to parts that you can parse.


Re: question - Gammix - 31.03.2018

I know the second one won't work properly as ZCMD only parses the command name and the rest goes into "params".

So you simply just changed "params" to "str" which is not wrong but "target" will simply hold 0 always.