if(strcmp(cmd, "/sellhouseto", true) == 0)
{
if(IsPlayerConnected(playerid))
{
GetPlayerName(playerid, playername, sizeof(playername));
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SCM(playerid, COLOR_GRAD1, "USAGE: /sellhouseto [playerid/PartOfName] [price]");
return 1;
}
giveplayerid = ReturnUser(tmp);
if(giveplayerid != INVALID_PLAYER_ID)
{
if(!strlen(tmp))
{
SCM(playerid, COLOR_GRAD1, "USAGE: /sellhouseto [playerid/PartOfName] [price]");
return 1;
}
new price,house;
GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
house = PlayerInfo[playerid][pHouseKey];
price = strval(tmp);
if(price < 1 || price > 2000000) return SCM(playerid, COLOR_GRAD1, "Price can't be lower than 1 or higher than 2000000!");
if(PlayerInfo[playerid][pHouseKey] == 9999)
{
SCM(playerid, COLOR_WHITE, "You don't own a house.");
return 1;
}
if(PlayerInfo[playerid][pHouseKey] != 9999 && strcmp(playername, HouseInfo[PlayerInfo[playerid][pHouseKey]][hOwner], true) == 0)
{
format(string, sizeof(string),"%s Has offered you to buy his house for %i $.",playername, price);
SCM(giveplayerid, COLOR_RLRPGBLUE, string);
SCM(giveplayerid, COLOR_LIGHTGREEN,"To accept the offer, type /accept house");
format(string, sizeof(string),"You offered %s to buy your house for %i $.",giveplayer);
SCM(playerid, COLOR_RLRPGBLUE, string);
OfferHouse[giveplayerid] = playerid;
HouseInfo[house][hValue] = price;
OfferHouseKey[giveplayerid] = house;
}
}
else
{
SCM(playerid, COLOR_GREY,"Player is not online");
return 1;
}
}
return 1;
}
|
I suggest you to move your commands to ZCMD. It's MUCH easier.
|
|
I didn't want any suggestions. I wanted an awnser on my question. I know zcmd is easier but I don't want to re-make all my cmds into zcmd and sscanf
|
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SCM(playerid, COLOR_GRAD1, "USAGE: /sellhouseto [playerid/PartOfName] [price]");
return 1;
}
giveplayerid = ReturnUser(tmp);
if(giveplayerid != INVALID_PLAYER_ID)
{
if(!strlen(tmp))
{
SCM(playerid, COLOR_GRAD1, "USAGE: /sellhouseto [playerid/PartOfName] [price]");
return 1;
}
new price,house;
GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
house = PlayerInfo[playerid][pHouseKey];
price = strval(tmp);
if(strcmp(cmd, "/sellhouseto", true) == 0)
{
if(IsPlayerConnected(playerid))
{
GetPlayerName(playerid, playername, sizeof(playername));
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SCM(playerid, COLOR_GRAD1, "USAGE: /sellhouseto [playerid/PartOfName] [price]");
return 1;
}
giveplayerid = ReturnUser(tmp);
if(giveplayerid != INVALID_PLAYER_ID)
{
if(!strlen(tmp))
{
SCM(playerid, COLOR_GRAD1, "USAGE: /sellhouseto [playerid/PartOfName] [price]");
return 1;
}
new price,house;
GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
house = PlayerInfo[playerid][pHouseKey];
tmp = strtok(cmdtext, idx);
price = strval(tmp);
if(price < 1 || price > 2000000) return SCM(playerid, COLOR_GRAD1, "Price can't be lower than 1 or higher than 2000000!");
if(PlayerInfo[playerid][pHouseKey] == 9999)
{
SCM(playerid, COLOR_WHITE, "You don't own a house.");
return 1;
}
if(PlayerInfo[playerid][pHouseKey] != 9999 && strcmp(playername, HouseInfo[PlayerInfo[playerid][pHouseKey]][hOwner], true) == 0)
{
format(string, sizeof(string),"%s Has offered you to buy his house for %i $.",playername, price);
SCM(giveplayerid, COLOR_RLRPGBLUE, string);
SCM(giveplayerid, COLOR_LIGHTGREEN,"To accept the offer, type /accept house");
format(string, sizeof(string),"You offered %s to buy your house for %i $.",giveplayer);
SCM(playerid, COLOR_RLRPGBLUE, string);
OfferHouse[giveplayerid] = playerid;
HouseInfo[house][hValue] = price;
OfferHouseKey[giveplayerid] = house;
}
}
else
{
SCM(playerid, COLOR_GREY,"Player is not online");
return 1;
}
}
return 1;
}
|
Using ZCMD would make it a lot clearer and easier to understand why it isnt working.
Anyway, it looks like you have only used strtok once on the variable tmp and you are using that for both the playerid and price. I don't exactly know how strtok works, but that looks like it is the cause of the problem. Код:
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SCM(playerid, COLOR_GRAD1, "USAGE: /sellhouseto [playerid/PartOfName] [price]");
return 1;
}
giveplayerid = ReturnUser(tmp);
if(giveplayerid != INVALID_PLAYER_ID)
{
if(!strlen(tmp))
{
SCM(playerid, COLOR_GRAD1, "USAGE: /sellhouseto [playerid/PartOfName] [price]");
return 1;
}
new price,house;
GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
house = PlayerInfo[playerid][pHouseKey];
price = strval(tmp);
|
|
There you go:
pawn Код:
|