Help me change this to CMD:
#1

Code :
Quote:

public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[24], params[64], len = strlen(cmdtext);

for (new i; i < len; i++) if (cmdtext[i] == ' ')
{
strmid(cmd, cmdtext, 0, i);
strcat(params, cmdtext[i + 1]);
break;
}
if (isnull(cmd)) strcat(cmd, cmdtext);

if (!strcmp(cmd, "/weapon", true))
{
new weaponid = GetPlayerWeapon(playerid);

if (!weaponid)
return SendClientMessage(playerid, -1, "Ban khong cam vu khi tren tay");

if (!IsWeaponWearable(weaponid))
return SendClientMessage(playerid, -1, "Vu khi nay khong the chinh sua duoc");

if (isnull(params))
return SendClientMessage(playerid, -1, "Su dung: /weapon [adjustpos/bone/hide]");

if (!strcmp(params, "adjustpos", true))
{
if (EditingWeapon[playerid])
return SendClientMessage(playerid, -1, "Ban da chinh sua xong vu khi.");

if (WeaponSettings[playerid][weaponid - 22][Hidden])
return SendClientMessage(playerid, -1, "Ban khong the dieu chinh vu khi nay an duoc.");

new index = weaponid - 22;

SetPlayerArmedWeapon(playerid, 0);

SetPlayerAttachedObject(playerid, GetWeaponObjectSlot(weaponid), GetWeaponModel(weaponid), WeaponSettings[playerid][index][Bone], WeaponSettings[playerid][index][Position][0], WeaponSettings[playerid][index][Position][1], WeaponSettings[playerid][index][Position][2], WeaponSettings[playerid][index][Position][3], WeaponSettings[playerid][index][Position][4], WeaponSettings[playerid][index][Position][5], 1.0, 1.0, 1.0);
EditAttachedObject(playerid, GetWeaponObjectSlot(weaponid));

EditingWeapon[playerid] = weaponid;
}
else if (!strcmp(params, "bone", true))
{
if (EditingWeapon[playerid])
return SendClientMessage(playerid, -1, "Ban da chinh sua vu khi tren co the ban thanh cong.");

ShowPlayerDialog(playerid, DIALOG_EDIT_BONE, DIALOG_STYLE_LIST, "Bone", "Cot song\nDau\nTren tay trai\nCanh tay phai\nTay trai\nTay phai\nDui trai\nDui phai\nChan trai\nChan phai\nBap chan phai\nBap chan trai\nCanh tay trai\nCanh tay phai\nXuong don trai\nXuong don phai\nCo\nQuay ham", "Luu chon", "Huy bo");
EditingWeapon[playerid] = weaponid;
}
else if (!strcmp(params, "hide", true))
{
if (EditingWeapon[playerid])
return SendClientMessage(playerid, -1, "Ban khong the giau vu khi trong khi dang chinh sua.");

if (!IsWeaponHideable(weaponid))
return SendClientMessage(playerid, -1, "Vu khi nay khong the an giau.");

new index = weaponid - 22, weaponname[18], name[MAX_PLAYER_NAME], string[150];

GetWeaponName(weaponid, weaponname, sizeof(weaponname));
GetPlayerName(playerid, name, MAX_PLAYER_NAME);

if (WeaponSettings[playerid][index][Hidden])
{
format(string, sizeof(string), "Ban da dat %s hien thi.", weaponname);
WeaponSettings[playerid][index][Hidden] = false;
}
else
{
if (IsPlayerAttachedObjectSlotUsed(playerid, GetWeaponObjectSlot(weaponid)))
RemovePlayerAttachedObject(playerid, GetWeaponObjectSlot(weaponid));

format(string, sizeof(string), "Ban da dat %s khong hien thi.", weaponname);
WeaponSettings[playerid][index][Hidden] = true;
}
SendClientMessage(playerid, -1, string);

mysql_format(database, string, sizeof(string), "INSERT INTO weaponsettings (Name, WeaponID, Hidden) VALUES ('%s', %d, %d) ON DUPLICATE KEY UPDATE Hidden = VALUES(Hidden)", name, weaponid, WeaponSettings[playerid][index][Hidden]);
mysql_tquery(database, string, "", "");
}
else SendClientMessage(playerid, -1, "Ban da chi dinh tuy chon khong hop le.");
return 1;
}
return 0;
}

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)