sscanf Z parameter.
#1

Can someone please tell me what's wrong with my script here?

Код:
CMD:house(playerid, params[])
{
	new string[256], slot;
    if(sscanf(params,"s[256]z", string, slot)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /house [buy/sell/lock/unlock/putgun/takegun/inventory]");
    if(!strcmp(string, "buy", true))
    {
		BuyHouseForPlayer(playerid);
		return 1;
    }
    if(!strcmp(string, "sell", true))
    {
		SellHouseForPlayer(playerid);
		return 1;
    }
    if(!strcmp(string, "lock", true))
    {
		LockPlayerHouse(playerid);
		return 1;
    }
    if(!strcmp(string, "unlock", true))
    {
		UnlockPlayerHouse(playerid);
		return 1;
    }
    if(!strcmp(string, "putgun", true))
    {
		PutGunPlayerHouse(playerid, slot);
		return 1;
    }
    if(!strcmp(string, "takegun", true))
    {
		TakeGunPlayerHouse(playerid, slot);
		return 1;
    }
    if(!strcmp(string, "inventory", true))
    {
		CheckPlayerHouseInventory(playerid);
		return 1;
    }
    else
    {
        SendClientMessage(playerid, COLOR_GREY, "USAGE: /house [buy/sell/lock/unlock/putgun/takegun/inventory]");
    }
	return 1;
}
Reply
#2

don't exists Z parameter.
pawn Код:
CMD:house(playerid, params[])
{
    new
        string[50]
    ;
    if(sscanf(params,"s[50]", string))
        return SendClientMessage(playerid, COLOR_GREY, "USAGE: /house [buy/sell/lock/unlock/putgun/takegun/inventory]");

    if(!strcmp(string, "buy", true))
    {
        BuyHouseForPlayer(playerid);
        return 1;
    }
    if(!strcmp(string, "sell", true))
    {
        SellHouseForPlayer(playerid);
        return 1;
    }
    if(!strcmp(string, "lock", true))
    {
        LockPlayerHouse(playerid);
        return 1;
    }
    if(!strcmp(string, "unlock", true))
    {
        UnlockPlayerHouse(playerid);
        return 1;
    }
    if(!strcmp(string, "putgun", true))
    {
        PutGunPlayerHouse(playerid, slot);
        return 1;
    }
    if(!strcmp(string, "takegun", true))
    {
        TakeGunPlayerHouse(playerid, slot);
        return 1;
    }
    if(!strcmp(string, "inventory", true))
    {
        CheckPlayerHouseInventory(playerid);
        return 1;
    }
   
    return 1;
}
Reply
#3

Quote:
Originally Posted by [Full]Garfield[XDB]
Посмотреть сообщение
don't exists Z parameter.
pawn Код:
CMD:house(playerid, params[])
{
    new
        string[50]
    ;
    if(sscanf(params,"s[50]", string))
        return SendClientMessage(playerid, COLOR_GREY, "USAGE: /house [buy/sell/lock/unlock/putgun/takegun/inventory]");

    if(!strcmp(string, "buy", true))
    {
        BuyHouseForPlayer(playerid);
        return 1;
    }
    if(!strcmp(string, "sell", true))
    {
        SellHouseForPlayer(playerid);
        return 1;
    }
    if(!strcmp(string, "lock", true))
    {
        LockPlayerHouse(playerid);
        return 1;
    }
    if(!strcmp(string, "unlock", true))
    {
        UnlockPlayerHouse(playerid);
        return 1;
    }
    if(!strcmp(string, "putgun", true))
    {
        PutGunPlayerHouse(playerid, slot);
        return 1;
    }
    if(!strcmp(string, "takegun", true))
    {
        TakeGunPlayerHouse(playerid, slot);
        return 1;
    }
    if(!strcmp(string, "inventory", true))
    {
        CheckPlayerHouseInventory(playerid);
        return 1;
    }
   
    return 1;
}
The Z was meant as the id of the slot.

Код:
    if(!strcmp(string, "putgun", true))
    {
		PutGunPlayerHouse(playerid, slot);
		return 1;
    }
    if(!strcmp(string, "takegun", true))
    {
		TakeGunPlayerHouse(playerid, slot);
		return 1;
    }
Reply
#4

You could use the optional specifier option
pawn Код:
if(sscanf(params,"s[50]I(-1)", string , slot ))
This will allow the code to process the string, and ignore the next parameter until it is needed.
Reply
#5

Quote:
Originally Posted by Rachael
Посмотреть сообщение
You could use the optional specifier option
pawn Код:
if(sscanf(params,"s[50]I(-1)", string , slot ))
This will allow the code to process the string, and ignore the next parameter until it is needed.
Yea, i just figured it out.
I was a dumbass and didn't look in the sscanf official post.

Код:
CMD:house(playerid, params[])
{
	new string[256], slot;
    if(sscanf(params,"s[256]I(1)", string, slot)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /house [buy/sell/lock/unlock/putgun/takegun/inventory]");
    if(!strcmp(string, "buy", true))
    {
		BuyHouseForPlayer(playerid);
		return 1;
    }
    if(!strcmp(string, "sell", true))
    {
		SellHouseForPlayer(playerid);
		return 1;
    }
    if(!strcmp(string, "lock", true))
    {
		LockPlayerHouse(playerid);
		return 1;
    }
    if(!strcmp(string, "unlock", true))
    {
		UnlockPlayerHouse(playerid);
		return 1;
    }
    if(!strcmp(string, "putgun", true))
    {
		PutGunPlayerHouse(playerid, slot);
		return 1;
    }
    if(!strcmp(string, "takegun", true))
    {
		TakeGunPlayerHouse(playerid, slot);
		return 1;
    }
    if(!strcmp(string, "inventory", true))
    {
		CheckPlayerHouseInventory(playerid);
		return 1;
    }
    else
    {
        SendClientMessage(playerid, COLOR_GREY, "USAGE: /house [buy/sell/lock/unlock/putgun/takegun/inventory]");
    }
	return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)