16.05.2010, 15:48
Hello,
This afternoon, ive made this code. It's a /giveweapon cmd with 3 parameters:
If i execute this command, he show me the message "use a correct weaponid [0-46]". I think the parameters are screwed up by me, but i dont know how to fix it. Ive learned myself DCMD with a few tut's some days ago, and this is my first DCMD cmd with multiple parameters. Please help me,
Greetz,
sean5874
This afternoon, ive made this code. It's a /giveweapon cmd with 3 parameters:
Код:
dcmd_giveweapon(playerid, params[]) { if(adminlevel[playerid] == 0) { SendClientMessage(playerid, ADMINFS_MESSAGE_COLOR,"You are not an Admin!"); return 1; } new giveplayerid, weaponID, ammo; if(!strlen(params)) { SendClientMessage(playerid, 0xFF0000AA, "USAGE: /giveplayerweapon [id] [weaponid] [ammo]"); return 1; } giveplayerid = strval(params); if(!strlen(params)) { SendClientMessage(playerid, 0xFF0000AA, "USAGE: /giveplayerweapon [id] [weaponid] [ammo]"); return 1; } weaponID = strval(params); if(!strlen(params)) { SendClientMessage(playerid, 0xFF0000AA, "USAGE: /giveplayerweapon [id] [weaponid] [ammo]"); return 1; } ammo = strval(params); if(!IsPlayerConnected(giveplayerid)) { SendClientMessage(playerid, 0xFF0000AA, "That player is offline."); return 1; } if(weaponID < 1 || weaponID > 46) { SendClientMessage(playerid, 0xFF0000AA, "Use an correct weaponid! [0-46]"); return 1; } if(ammo < 1) { SendClientMessage(playerid, 0xFF0000AA, "You must give at least ammo 1."); return 1; } new string[256]; new string2[256]; GetPlayerName(giveplayerid, gname, sizeof (gname)); GivePlayerWeapon(giveplayerid, weaponID, ammo); format(string,sizeof(string),"Admin %s has given you weapon %d with %d ammo!",pname,weaponID,ammo); format(string2,sizeof(string2),"You have given weapon %d to player %s",weaponID,gname); SendClientMessage(giveplayerid, ADMINFS_MESSAGE_COLOR, string); SendClientMessage(playerid, ADMINFS_MESSAGE_COLOR, string2); return 1; }
Greetz,
sean5874