dimanche 1 mars 2015

Command question



Quote:








if(strcmp(subcmd, "arme", true) == 0)

{

if(PlayerInfo[playerid][pAdmin] < COFONDA){return NotAdmin(playerid,cmd);}



tmp = strtok(cmdtext, idx);

if(!strlen(tmp))

{return SendCmdModelMessage(playerid, "/donnerarme <ID/Pseudo> <Munitions> <Arme ID/Nom>");}

new giveplayerid = ReturnUser(tmp);







new length = strlen(cmdtext);

while ((idx < length) && (cmdtext[idx] <= ' '))

{idx++;}

new offset = idx;

new result[64];

while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))

{result[idx-offset] = cmdtext[idx]; idx++;}

result[idx - offset] = EOS;

if(!strlen(result))

{return SendCmdModelMessage(playerid, "/donnerarme <ID/Pseudo> <Munitions> <Arme ID/Nom>");}







tmp = strtok(cmdtext, idx);

if(!strlen(tmp))

{return SendCmdModelMessage(playerid, "/donnerarme <ID/Pseudo> <Munitions> <Arme ID/Nom>");}

new ammo = strval(tmp);



new amount = GetWeaponModelFromName(result);



GetPlayerName(playerid, playername,sizeof(playername));

GetPlayerName(giveplayerid, giveplayername,sizeof(giveplayername));



SafeGivePlayerWeapon(giveplayerid, amount, ammo);

return 1;

}



Hi,



I want to do this /giveweapon command and I would like to have it with this form:



/giveweapon <ID> <Name Of Weapon> <Ammo>



The problem is that the Name of the Weapon is a string and when I tape the command in game, the ammo part is "taking" by the Name string.



Is there a way to stop the string detection just before the ammo option ?




Aucun commentaire:

Enregistrer un commentaire