SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 12/02/2018, 08:27 PM   #1
EvgeniyHostel1992
Little Clucker
 
Join Date: Feb 2016
Posts: 10
Reputation: 0
Default Update OnPlayerCommand > sscanf zcmd

Give at least a brief example of how to convert the / edit command from gif to cmd: (sscanf zcmd)
PHP Code:
if(strcmp(cmd"/edit"true) == 0)
    {
        if(
IsPlayerConnected(playerid))
        {
            if(
pl[playerid][pAdmin] < 4)
            {
                
SendClientMessage(playeridCOLOR_GRAD2"   You are not an Admin !");
                return 
1;
            }
            new 
x_job[256];
            
x_job strtok(cmdtextidx);
            if(!
strlen(x_job)) {
                
SendClientMessage(playeridCOLOR_WHITE"|__________________ Edit __________________|");
                
SendClientMessage(playeridCOLOR_WHITE"USAGE: /edit [name] [ammount] (Used for Houses and Businesses)");
                
SendClientMessage(playeridCOLOR_GREY"Available names: Level, Price, Funds, Products");
                
SendClientMessage(playeridCOLOR_WHITE"|____________________________________________|");
                return 
1;
            }
            
tmp strtok(cmdtextidx);
            if(!
strlen(tmp))
            {
                
SendClientMessage(playeridCOLOR_GRAD2"USAGE: /edit [name] [ammount]");
                return 
1;
            }
            new 
proplev strval(tmp);
            
//if(strcmp(x_job,"car",true) == 0)
            
for(new 0sizeof(HouseInfo); i++)
            {
                if (
PlayerToPoint(3playerid,HouseInfo[i][hEntrancex], HouseInfo[i][hEntrancey], HouseInfo[i][hEntrancez]))
                {
                    
format(stringsizeof(string), "House: %d"i);
                    
SendClientMessage(playeridCOLOR_GRAD2string);
                    if(
proplev 0)
                    {
                        if(
strcmp(x_job,"level",true) == 0)
                        {
                            
HouseInfo[i][hLevel] = proplev;
                        }
                        else if(
strcmp(x_job,"price",true) == 0)
                        {
                            
HouseInfo[i][hValue] = proplev;
                        }
                    }
                }
            }
            for(new 
0sizeof(BizzInfo); i++)
            {
                if (
PlayerToPoint(3playerid,BizzInfo[i][bEntranceX], BizzInfo[i][bEntranceY], BizzInfo[i][bEntranceZ]))
                {
                    
format(stringsizeof(string), "Biz: %d"i);
                    
SendClientMessage(playeridCOLOR_GRAD2string);
                    if(
proplev 0)
                    {
                        if(
strcmp(x_job,"level",true) == 0)
                        {
                            
BizzInfo[i][bLevelNeeded] = proplev;
                        }
                        else if(
strcmp(x_job,"price",true) == 0)
                        {
                            
BizzInfo[i][bBuyPrice] = proplev;
                        }
                        else if(
strcmp(x_job,"funds",true) == 0)
                        {
                            
BizzInfo[i][bTill] = proplev;
                        }
                        else if(
strcmp(x_job,"products",true) == 0)
                        {
                            
BizzInfo[i][bProducts] = proplev;
                        }
                    }
                }
            }
            for(new 
0sizeof(SBizzInfo); i++)
            {
                if (
PlayerToPoint(3playerid,SBizzInfo[i][sbEntranceX], SBizzInfo[i][sbEntranceY], SBizzInfo[i][sbEntranceZ]))
                {
                    
format(stringsizeof(string), "SBiz: %d"i);
                    
SendClientMessage(playeridCOLOR_GRAD2string);
                    if(
proplev 0)
                    {
                        if(
strcmp(x_job,"level",true) == 0)
                        {
                            
SBizzInfo[i][sbLevelNeeded] = proplev;
                        }
                        else if(
strcmp(x_job,"price",true) == 0)
                        {
                            
SBizzInfo[i][sbBuyPrice] = proplev;
                        }
                        else if(
strcmp(x_job,"funds",true) == 0)
                        {
                            
SBizzInfo[i][sbTill] = proplev;
                        }
                        else if(
strcmp(x_job,"products",true) == 0)
                        {
                            
SBizzInfo[i][sbProducts] = proplev;
                        }
                    }
                }
            }
            
format(stringsizeof(string), "You've adjusted the: %s."x_job);
            
SendClientMessage(playeridCOLOR_WHITEstring);
            
OnPropUpdate();
        }
        return 
1;
    } 
examples of such simple I know:
PHP Code:
CMD:setskin(playeridparams[]){
    new 
skinid;
    if(
sscanf(params,"d"skinid))
    return 
send(playeridCOLOR_GRAD1"USAGE: /setskin [skin]");
    
SetPlayerSkin(playerid,skinid);
    
pl[playerid][pChar]=skinid;
    return 
1;} 
Please at least an example(
__________________
The Godfather 2007 [Roley Play]
EvgeniyHostel1992 is offline   Reply With Quote
Old 12/02/2018, 09:28 PM   #2
Mugala
Gangsta
 
Mugala's Avatar
 
Join Date: Nov 2012
Location: behind u
Posts: 526
Reputation: 23
Default Re: Update OnPlayerCommand > sscanf zcmd

PHP Code:
CMD:edit(playerid,params[])

    if(
IsPlayerConnected(playerid)) 
    { 
        if(
pl[playerid][pAdmin] < 4
        { 
            
SendClientMessage(playeridCOLOR_GRAD2"   You are not an Admin !"); 
            return 
1
        } 
        new 
name[16],ammount;
        if(
sscanf(params,"s[16]d"nameammount))
        {
            
SendClientMessage(playeridCOLOR_WHITE"|__________________ Edit __________________|"); 
            
SendClientMessage(playeridCOLOR_WHITE"USAGE: /edit [name] [ammount] (Used for Houses and Businesses)"); 
            
SendClientMessage(playeridCOLOR_GREY"Available names: Level, Price, Funds, Products"); 
            
SendClientMessage(playeridCOLOR_WHITE"|____________________________________________|"); 
            return 
1
        } 
        for(new 
0sizeof(HouseInfo); i++) 
        { 
            if (
PlayerToPoint(3playerid,HouseInfo[i][hEntrancex], HouseInfo[i][hEntrancey], HouseInfo[i][hEntrancez])) 
            { 
                
format(stringsizeof(string), "House: %d"i); 
                
SendClientMessage(playeridCOLOR_GRAD2string); 
                if(
ammount 0
                { 
                    if(
strcmp(name,"level",true) == 0
                    { 
                        
HouseInfo[i][hLevel] = ammount
                    } 
                    else if(
strcmp(name,"price",true) == 0
                    { 
                        
HouseInfo[i][hValue] = ammount
                    } 
                } 
            } 
        } 
        for(new 
0sizeof(BizzInfo); i++) 
        { 
            if (
PlayerToPoint(3playerid,BizzInfo[i][bEntranceX], BizzInfo[i][bEntranceY], BizzInfo[i][bEntranceZ])) 
            { 
                
format(stringsizeof(string), "Biz: %d"i); 
                
SendClientMessage(playeridCOLOR_GRAD2string); 
                if(
ammount 0
                { 
                    if(
strcmp(name,"level",true) == 0
                    { 
                        
BizzInfo[i][bLevelNeeded] = ammount
                    } 
                    else if(
strcmp(name,"price",true) == 0
                    { 
                        
BizzInfo[i][bBuyPrice] = ammount
                    } 
                    else if(
strcmp(name,"funds",true) == 0
                    { 
                        
BizzInfo[i][bTill] = ammount
                    } 
                    else if(
strcmp(name,"products",true) == 0
                    { 
                        
BizzInfo[i][bProducts] = ammount
                    } 
                } 
            } 
        } 
        for(new 
0sizeof(SBizzInfo); i++) 
        { 
            if (
PlayerToPoint(3playerid,SBizzInfo[i][sbEntranceX], SBizzInfo[i][sbEntranceY], SBizzInfo[i][sbEntranceZ])) 
            { 
                
format(stringsizeof(string), "SBiz: %d"i); 
                
SendClientMessage(playeridCOLOR_GRAD2string); 
                if(
ammount 0
                { 
                    if(
strcmp(name,"level",true) == 0
                    { 
                        
SBizzInfo[i][sbLevelNeeded] = ammount
                    } 
                    else if(
strcmp(name,"price",true) == 0
                    { 
                        
SBizzInfo[i][sbBuyPrice] = ammount
                    } 
                    else if(
strcmp(name,"funds",true) == 0
                    { 
                         
SBizzInfo[i][sbTill] = ammount
                    } 
                    else if(
strcmp(name,"products",true) == 0
                    { 
                        
SBizzInfo[i][sbProducts] = ammount
                    } 
                } 
            } 
        } 
        
format(stringsizeof(string), "You've adjusted the: %s."name); 
        
SendClientMessage(playeridCOLOR_WHITEstring); 
        
OnPropUpdate(); 
    } 
    return 
1

__________________
here to help
Mugala is offline   Reply With Quote
Old 13/02/2018, 02:00 PM   #3
EvgeniyHostel1992
Little Clucker
 
Join Date: Feb 2016
Posts: 10
Reputation: 0
Default Re: Update OnPlayerCommand > sscanf zcmd

s[16] ? - [16] what this?
__________________
The Godfather 2007 [Roley Play]
EvgeniyHostel1992 is offline   Reply With Quote
Old 13/02/2018, 02:18 PM   #4
KaRToNiToS
Little Clucker
 
KaRToNiToS's Avatar
 
Join Date: Feb 2018
Posts: 2
Reputation: 0
Default Re: Update OnPlayerCommand > sscanf zcmd

Code:
  Specifiers:

	Format					Use
	L(true/false)				Optional logical truthity
	l					Logical truthity
	B(binary)				Optional binary number
	b					Binary number
	N(any format number)			Optional number
	n					Number
	C(character)				Optional character
	c					Character
	I(integer)				Optional integer
	i					Integer
	D(integer)				Optional integer
	d					Integer
	H(hex value)				Optional hex number
	h					Hex number
	O(octal value)				Optional octal value
	o					Octal value
	F(float)				Optional floating point number
	f					Floating point number
	G(float/INFINITY/-INFINITY/NAN/NAN_E)	Optional float with IEEE definitions
	g					Float with IEEE definitions
	{					Open quiet section
	}					Close quiet section
	P<delimiter>				Invalid delimiter change
	p<delimiter>				Delimiter change
	Z(string)[length]			Invalid optional string
	z(string)[length]			Deprecated optional string
	S(string)[length]			Optional string
	s[length]				String
	U(name/id)				Optional user (bot/player)
	u					User (bot/player)
	Q(name/id)				Optional bot (bot)
	q					Bot (bot)
	R(name/id)				Optional player (player)
	r					Player (player)
	A<type>(default)[length]		Optional array of given type
	a<type>[length]				Array of given type
	E<specification>(default)		Optional enumeration of given layout
	e<specification>			Enumeration of given layout
	'string'				Search string
	%					Deprecated optional specifier prefix
KaRToNiToS 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
zcmd or onplayercommand? TheSkyBlueTeam Scripting Help 4 25/07/2015 01:52 AM
ID bug when I update sscanf. PrinceOfPersia Server Support 5 22/05/2014 10:01 PM
sscanf & zcmd help..! sscanf inside strcmp PaulDinam Scripting Help 2 26/02/2013 01:47 PM
SSCANF update 7 error Smally Scripting Help 1 09/03/2012 04:11 PM


All times are GMT. The time now is 12:25 PM.


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