14.01.2012, 01:12
pawn Код:
dcmd_w2(playerid, params[])
{
new idx, iString[128];
iString = strtok(params, idx);
if (!strlen(iString)) {
SendClientMessage(playerid, COLOR_RED, "[USAGE]: /w2 WEAPONID/NAME (AMMO) or /weapon WEAPONID/NAME (AMMO)");
return true;
}
new weaponid = GetWeaponModelIDFromName(iString);
if (weaponid == -1) {
weaponid = strval(iString);
if (weaponid < 0 || weaponid > 47) {
SendClientMessage(playerid, COLOR_RED, "[ERROR]: Invalid WEAPONID/NAME");
return true;
}
}
if (!strlen(params[idx+1])) {
GivePlayerWeapon(playerid, weaponid, 500);
format(iString, 128, "[SUCCESS]: You were given weapon %s (ID: %d) with 500 ammo.", aWeaponNames[weaponid], weaponid);
SendClientMessage(playerid, COLOR_GREEN, iString);
return true;
}
idx = strval(params[idx+1]);
GivePlayerWeapon(playerid, weaponid, idx);
format(iString, 128, "[SUCCESS]: You were given weapon %s (ID: %d) with %d ammo.", aWeaponNames[weaponid], weaponid, idx);
SendClientMessage(playerid, COLOR_GREEN, iString);
return true;
}
Check that out and maybe you'll get an idea.