This cmd just dont send msg and dont do the functions that i made.The server dont says unknown cmd....
PHP код:
CMD:sellmycar(playerid, params[])
{
new string[128], playerb;
if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
if(!IsPlayerNearPlayer(playerid, playerb, 2)) return SendClientMessage(playerid, COLOR_GREY, "You are too far away from that player.");
if(!PlayerInfo[playerid][pVeh] && !PlayerInfo[playerid][pVVeh] && !PlayerInfo[playerid][pVVVeh]) return SendClientMessage(playerid, COLOR_GREY, "You don't own a vehicle.");
if(sscanf(params, "uis[64]", playerb, carslot, carprice)) return SendClientMessage(playerid, COLOR_WHITE, "[Usage]: /sellmycar [playerid] [slot] [price]");
if(!IsPlayerLoggedIn(playerb)) return SendClientMessage(playerid, COLOR_GREY, "Invalid player id.");
if(playerid == playerb) return SendClientMessage(playerid, COLOR_GREY, "You can't sell your car to yourself.");
if(carprice == 0) return SendClientMessage(playerid, COLOR_GREY, "You cant sell your car for 0$.");
if(carslot < 1 || carslot > 4) return SendClientMessage(playerid, COLOR_WHITE, "There are only 4 car slots");
switch(carslot)
{
case 1:
{
if(PlayerInfo[playerid][vModel] == 0) return SendClientMessage(playerid, COLOR_GREY, "You dont have vehicle in this slot.");
new Float:vx, Float:vy, Float:vz;
GetVehiclePos(PlayerInfo[playerid][pVeh], vx, vy, vz);
if(IsPlayerInRangeOfPoint(playerid, 4, vx, vy, vz)) return SendClientMessage(playerid, COLOR_GREY, "You are not near your car.");
format(string, sizeof(string), " You have offered your %s to %s for $%d.",RVN(PlayerInfo[playerid][vModel]), RPN(playerb), carprice);
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
format(string, sizeof(string), "%s has offered you his/her %s for $%d. (/accept car) (/cancel car)",RPN(playerid), RVN(PlayerInfo[playerid][vModel]), carprice);
SendClientMessage(playerb, COLOR_YELLOW, string);
CarBy[playerb] = playerid;
Car[playerb] = 0;
offeredcar[playerb] = 1;
}
case 2:
{
if(PlayerInfo[playerid][vVModel] == 0) return SendClientMessage(playerid, COLOR_GREY, "You dont have vehicle in this slot.");
new Float:vx, Float:vy, Float:vz;
GetVehiclePos(PlayerInfo[playerid][pVVeh], vx, vy, vz);
if(IsPlayerInRangeOfPoint(playerid, 4, vx, vy, vz)) return SendClientMessage(playerid, COLOR_GREY, "You are not near your car.");
format(string, sizeof(string), " You have offered your %s to %s for $%d.",RVN(PlayerInfo[playerid][vVModel]), RPN(playerb), carprice);
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
format(string, sizeof(string), "%s has offered you his/her %s for $%d. (/accept car) (/cancel car)",RPN(playerid), RVN(PlayerInfo[playerid][vVModel]), carprice);
SendClientMessage(playerb, COLOR_YELLOW, string);
CarBy[playerb] = playerid;
Car[playerb] = 0;
offeredcar[playerb] = 2;
}
case 3:
{
if(PlayerInfo[playerid][vVVModel] == 0) return SendClientMessage(playerid, COLOR_GREY, "You dont have vehicle in this slot.");
new Float:vx, Float:vy, Float:vz;
GetVehiclePos(PlayerInfo[playerid][pVVVeh], vx, vy, vz);
if(IsPlayerInRangeOfPoint(playerid, 4, vx, vy, vz)) return SendClientMessage(playerid, COLOR_GREY, "You are not near your car.");
format(string, sizeof(string), " You have offered your %s to %s for $%d.",RVN(PlayerInfo[playerid][vVVModel]), RPN(playerb), carprice);
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
format(string, sizeof(string), "%s has offered you his/her %s for $%d. (/accept car) (/cancel car)",RPN(playerid), RVN(PlayerInfo[playerid][vVVModel]), carprice);
SendClientMessage(playerb, COLOR_YELLOW, string);
CarBy[playerb] = playerid;
Car[playerb] = 0;
offeredcar[playerb] = 3;
}
case 4:
{
if(PlayerInfo[playerid][vVVVModel] == 0) return SendClientMessage(playerid, COLOR_GREY, "You dont have vehicle in this slot.");
new Float:vx, Float:vy, Float:vz;
GetVehiclePos(PlayerInfo[playerid][pVVVVeh], vx, vy, vz);
if(IsPlayerInRangeOfPoint(playerid, 4, vx, vy, vz)) return SendClientMessage(playerid, COLOR_GREY, "You are not near your car.");
format(string, sizeof(string), " You have offered your %s to %s for $%d.",RVN(PlayerInfo[playerid][vVVVModel]), RPN(playerb), carprice);
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
format(string, sizeof(string), "%s has offered you his/her %s for $%d. (/accept car) (/cancel car)",RPN(playerid), RVN(PlayerInfo[playerid][vVVModel]), carprice);
SendClientMessage(playerb, COLOR_YELLOW, string);
CarBy[playerb] = playerid;
Car[playerb] = 0;
offeredcar[playerb] = 4;
}
}
return 1;
}
You've declared "playerb" but it doesn't hold any value (value = 0).
You're checking if the player is near playerid 0, with a distance of 2 meters.
PHP код:
CMD:sellmycar(playerid, params[])
{
for(new d = 0 ; d < MAX_PLAYERVEHICLES; d++)
{
if(IsPlayerInVehicle(playerid, PlayerVehicleInfo[playerid][d][pvId]))
{
new Float:health;
GetVehicleHealth(PlayerVehicleInfo[playerid][d][pvId], health);
if(PlayerInfo[playerid][pLevel] == 1)
{
SendClientMessageEx(playerid, COLOR_GREY, "You have to be level 2 or higher to be able to sell vehicles.");
return 1;
}
if(health < 500) return SendClientMessageEx(playerid, COLOR_GREY, " Your vehicle is too damaged to sell it.");
new string[128], giveplayerid, price;
if(sscanf(params, "ud", giveplayerid, price)) return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /sellmycar [playerid] [price]");
if(price < 1) return SendClientMessageEx(playerid, COLOR_GREY, "Price must be higher than 0.");
if(PlayerInfo[giveplayerid][pLevel] == 1)
{
SendClientMessageEx(playerid, COLOR_GREY, "The player has to be Level 2 or higher to be able to sell vehicles to them.");
return 1;
}
if(playerid == giveplayerid)
{
SendClientMessageEx(playerid, COLOR_GREY, "You can not use this command on yourself.");
return 1;
}
if(!IsPlayerConnected(giveplayerid)) return SendClientMessageEx(playerid, COLOR_GREY, "Player is currently not connected to the server.");
if (ProxDetectorS(8.0, playerid, giveplayerid))
{
VehicleOffer[giveplayerid] = playerid;
VehicleId[giveplayerid] = d;
VehiclePrice[giveplayerid] = price;
format(string, sizeof(string), "* You offered %s to buy this %s for $%d.", GetPlayerNameEx(giveplayerid), GetVehicleName(PlayerVehicleInfo[playerid][d][pvId]), price);
SendClientMessageEx(playerid, COLOR_LIGHTBLUE, string);
format(string, sizeof(string), "* %s has offered you their %s for $%d, (type /accept car) to buy.", GetPlayerNameEx(playerid), GetVehicleName(PlayerVehicleInfo[playerid][d][pvId]), price);
SendClientMessageEx(giveplayerid, COLOR_LIGHTBLUE, string);
return 1;
}
else
{
SendClientMessageEx(playerid, COLOR_GREY, "That player is not near you.");
return 1;
}
}
}
SendClientMessageEx(playerid, COLOR_GREY, " You need to be inside a vehicle that you own.");
return 1;
}