buyclothes command [ZCMD/sscanf] help me!
#1

pawn Код:
stock IsAPedSkin()
{
    new skinid;
    if(skinid == 9||skinid == 14||skinid == 21||skinid == 22||skinid == 38||skinid == 39||skinid == 40||skinid == 41||skinid == 43||skinid == 44||skinid == 46||skinid == 47||skinid == 48||skinid == 54)
    {
        return 1;
    }
    if(skinid == 55||skinid == 56||skinid == 57||skinid == 58||skinid == 59||skinid == 60||skinid == 69||skinid == 76||skinid == 88||skinid == 89||skinid == 93||skinid == 94||skinid == 95||skinid == 98)
    {
        return 1;
    }
    if(skinid == 101||skinid == 136||skinid == 151||skinid == 169||skinid == 170||skinid == 183||skinid == 184||skinid == 185||skinid == 186||skinid == 188||skinid == 215||skinid == 216||skinid == 218)
    {
        return 1;
    }
    if(skinid == 221||skinid == 222||skinid == 223||skinid == 224||skinid == 225||skinid == 226||skinid == 228||skinid == 229||skinid == 231||skinid == 232||skinid == 233||skinid == 235||skinid == 236||skinid == 250||skinid == 263||skinid == 299)
    {
        return 1;
    }
    return 1;
}

CMD:buyclothes(playerid,params[])
{
    new skinid;
    if(!IsPlayerInRangeOfPoint(playerid, 5, 207.6668,-100.4377,1005.2578)) return SendClientMessage(playerid, COLOR_GRAD1,"You are not near a clothes shop counter.");
    if(PlayerInfo[playerid][pMoney] <= 150) return SendClientMessage(playerid, COLOR_GRAD1,"You do not have enought money to purchase new clothes!");
    if(sscanf(params,"i", skinid)) return SendClientMessage(playerid, COLOR_GRAD1,"USAGE: /buyclothes [skinid]");
    if(IsAPedSkin())
    {
        SetPlayerSkin(playerid, skinid);
        GivePlayerMoney(playerid, -150);
        PlayerInfo[playerid][pMoney] = PlayerInfo[playerid][pMoney] - 150;
        return 1;
    }
    return 1;
}
I can choose any id even the ones that are not in IsAPetSkin() and the command works for any id please help me!
Reply
#2

It's because it's always returning the value of 1.
Reply
#3

so what should I do? s:
Reply
#4

Try this
Код:
stock IsAPedSkin(skinid)
{
	switch(skinid)
	{
		case 9,14,21,22,38..41,43,44,46..48,54..60,69,76,88,89,93..95,98: return 1;
		case 101,136,151,169,170,183..186,188,215,216,218,221..226,228,229,231..233,235,236,250,263,299: return 1;
		default: return 0;
	}
	return 0;

}

CMD:buyclothes(playerid,params[])
{
    new skinid;
    if(!IsPlayerInRangeOfPoint(playerid, 5, 207.6668,-100.4377,1005.2578)) return SendClientMessage(playerid, COLOR_GRAD1,"You are not near a clothes shop counter.");
    if(PlayerInfo[playerid][pMoney] <= 150) return SendClientMessage(playerid, COLOR_GRAD1,"You do not have enought money to purchase new clothes!");
    if(sscanf(params,"i", skinid)) return SendClientMessage(playerid, COLOR_GRAD1,"USAGE: /buyclothes [skinid]");
    if(IsAPedSkin(skinid))
    {
        SetPlayerSkin(playerid, skinid);
        GivePlayerMoney(playerid, -150);
        PlayerInfo[playerid][pMoney] = PlayerInfo[playerid][pMoney] - 150;
        return 1;
    }
    return 1;
}
Reply
#5

pawn Код:
stock IsAPedSkin(skinid)
{
    if(skinid == 9 || skinid == 14 || skinid == 21 || skinid == 22 || skinid == 38 || skinid == 39 || skinid == 40||skinid == 41||skinid == 43||skinid == 44||skinid == 46||skinid == 47||skinid == 48||skinid == 54)
    {
        return 1;
    }
    else if(skinid == 55||skinid == 56||skinid == 57||skinid == 58||skinid == 59||skinid == 60||skinid == 69||skinid == 76||skinid == 88||skinid == 89||skinid == 93||skinid == 94||skinid == 95||skinid == 98)
    {
        return 2;
    }
    else if(skinid == 101||skinid == 136||skinid == 151||skinid == 169||skinid == 170||skinid == 183||skinid == 184||skinid == 185||skinid == 186||skinid == 188||skinid == 215||skinid == 216||skinid == 218)
    {
        return 3;
    }
    else if(skinid == 221||skinid == 222||skinid == 223||skinid == 224||skinid == 225||skinid == 226||skinid == 228||skinid == 229||skinid == 231||skinid == 232||skinid == 233||skinid == 235||skinid == 236||skinid == 250||skinid == 263||skinid == 299)
    {
        return 4;
    }
    else return 0;
}
Reply
#6

Quote:
Originally Posted by Brandon_More
Посмотреть сообщение
pawn Код:
stock IsAPedSkin(skinid)
{
    if(skinid == 9 || skinid == 14 || skinid == 21 || skinid == 22 || skinid == 38 || skinid == 39 || skinid == 40||skinid == 41||skinid == 43||skinid == 44||skinid == 46||skinid == 47||skinid == 48||skinid == 54)
    {
        return 1;
    }
    else if(skinid == 55||skinid == 56||skinid == 57||skinid == 58||skinid == 59||skinid == 60||skinid == 69||skinid == 76||skinid == 88||skinid == 89||skinid == 93||skinid == 94||skinid == 95||skinid == 98)
    {
        return 2;
    }
    else if(skinid == 101||skinid == 136||skinid == 151||skinid == 169||skinid == 170||skinid == 183||skinid == 184||skinid == 185||skinid == 186||skinid == 188||skinid == 215||skinid == 216||skinid == 218)
    {
        return 3;
    }
    else if(skinid == 221||skinid == 222||skinid == 223||skinid == 224||skinid == 225||skinid == 226||skinid == 228||skinid == 229||skinid == 231||skinid == 232||skinid == 233||skinid == 235||skinid == 236||skinid == 250||skinid == 263||skinid == 299)
    {
        return 4;
    }
    else return 0;
}
What are you doing why return 2,3,4?
Reply
#7

Use switches, as awesomedude posted. It will work out better. Additionally, you are returning 1 so it will return that it is a ped skin even though it is not!
Reply
#8

It worked with switches thank you so much awesomedude! thats perfect!! +rep

--------------------------Topic Closed----------------------
Reply
#9

Quote:
Originally Posted by awsomedude
Посмотреть сообщение
What are you doing why return 2,3,4?
So then when it comes to the command:

pawn Код:
CMD:buyclothes(playerid,params[])
{
    new skinid;
    if(!IsPlayerInRangeOfPoint(playerid, 5, 207.6668,-100.4377,1005.2578)) return SendClientMessage(playerid, COLOR_GRAD1,"You are not near a clothes shop counter.");
    if(PlayerInfo[playerid][pMoney] <= 150) return SendClientMessage(playerid, COLOR_GRAD1,"You do not have enought money to purchase new clothes!");
    if(sscanf(params,"i", skinid)) return SendClientMessage(playerid, COLOR_GRAD1,"USAGE: /buyclothes [skinid]");
    if(IsAPedSkin(skinid) == 1)
    {
        SetPlayerSkin(playerid, skinid);
        GivePlayerMoney(playerid, -150);
        PlayerInfo[playerid][pMoney] = PlayerInfo[playerid][pMoney] - 150;
    }
    else if(IsAPedSkin(skinid) == 2)
    {
        SetPlayerSkin(playerid, skinid);
        GivePlayerMoney(playerid, -150);
        PlayerInfo[playerid][pMoney] = PlayerInfo[playerid][pMoney] - 150;
    }
    else if(IsAPedSkin(skinid) == 3)
    {
        SetPlayerSkin(playerid, skinid);
        GivePlayerMoney(playerid, -150);
        PlayerInfo[playerid][pMoney] = PlayerInfo[playerid][pMoney] - 150;
    }
    else if(IsAPedSkin(skinid) == 4)
    {
        SetPlayerSkin(playerid, skinid);
        GivePlayerMoney(playerid, -150);
        PlayerInfo[playerid][pMoney] = PlayerInfo[playerid][pMoney] - 150;
    }
    else
    {
        SetPlayerSkin(playerid, skinid);
        GivePlayerMoney(playerid, -150);
        PlayerInfo[playerid][pMoney] = PlayerInfo[playerid][pMoney] - 150;
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)