11.07.2014, 15:02
I encountered an issue while making this /givegun command where it will not tell you the name of the weapon, or actually any string information in game (in terms of the message that's sent where Admin %s has given %s a %s with %s, would just appear as "Admin has given a with" and would have some very odd characters. To combat this I tried to use the stock GetWeaponName. Now I'm receiving two errors and I still don't really know if the command will work. Here's all the code if someone could help me out with what's wrong here.
Edit: forgot to include the errors, sorry guys.
Код:
CMD:givegun(playerid, params[]) { if(PlayerInfo[playerid][pAdmin] >= 6) { new targetid, gun, ammo, string[128], string2[128], wname; if(sscanf(params, "uii", targetid, gun, ammo)) return SendClientMessage(playerid, -1, "/givegun [targetid] [gun] [ammo]"); if(gun > 47 || gun < 1) return SendClientMessage(playerid, -1, "The selected weapon ID is invalid - please select one between 1 and 47"); if(ammo > 99999 || ammo < 1) return SendClientMessage(playerid, -1, "The amount of ammo you chose is invalid - please select an amount between 1 and 99999(infinite)"); GivePlayerWeapon(targetid, gun, ammo); GetWeaponName(gun,wname,sizeof(wname)); format(string,sizeof(string),"Admin %s has given you a %s with %s ammo in it!",playerid,wname,ammo); SendClientMessage(targetid, -1, string); format(string2,sizeof(string2),"You have given %s a %s with %s ammo in it!",targetid,wname,ammo); SendClientMessage(playerid, -1, string2); } else { SendClientMessage(playerid, -1, "You are not a high enough leveled administrator to use this command!"); } return 1; }
Код:
stock GetGunName(gunid) { new res[24]; switch(gunid) { case 0: format(res,sizeof(res),"Fist"); case 1: format(res,sizeof(res),"Brass Knuckles"); case 2: format(res,sizeof(res),"Golf Club"); case 3: format(res,sizeof(res),"Nightstick"); case 4: format(res,sizeof(res),"Knife"); case 5: format(res,sizeof(res),"Baseball Bat"); case 6: format(res,sizeof(res),"Shovel"); case 7: format(res,sizeof(res),"Pool Cue"); case 8: format(res,sizeof(res),"Katana"); case 9: format(res,sizeof(res),"Chainsaw"); case 10: format(res,sizeof(res),"Double-ended Dildo"); case 11: format(res,sizeof(res),"Dildo"); case 12: format(res,sizeof(res),"Vibrator"); case 13: format(res,sizeof(res),"Silver Vibrator"); case 14: format(res,sizeof(res),"Flowers"); case 15: format(res,sizeof(res),"Cane"); case 16: format(res,sizeof(res),"Grenade"); case 17: format(res,sizeof(res),"Tear Gas"); case 18: { return weapon[0] = 0, strcat(weapon, "Molotov Cocktail", len), true; } case 22: format(res,sizeof(res),"9mm Pistol"); case 23: format(res,sizeof(res),"Silenced 9mm Pistol"); case 24: format(res,sizeof(res),"Desert Eagle"); case 25: format(res,sizeof(res),"Pump Shotgun"); case 26: format(res,sizeof(res),"Sawnoff Shotgun"); case 27: format(res,sizeof(res),"Combat Shotgun"); case 28: format(res,sizeof(res),"Uzi"); case 29: format(res,sizeof(res),"MP5"); case 30: format(res,sizeof(res),"AK-47"); case 31: format(res,sizeof(res),"M4"); case 32: format(res,sizeof(res),"Tec-9"); case 33: format(res,sizeof(res),"Country Rifle"); case 34: format(res,sizeof(res),"Sniper Rifle"); case 35: format(res,sizeof(res),"RPG"); case 36: format(res,sizeof(res),"Heat Seeker"); case 37: format(res,sizeof(res),"Flamethrower"); case 38: format(res,sizeof(res),"Minigun"); case 39: format(res,sizeof(res),"Satchel Charge"); case 40: format(res,sizeof(res),"Detonator"); case 41: format(res,sizeof(res),"Pepper Spray"); case 42: format(res,sizeof(res),"Fire Extinguisher"); case 43: format(res,sizeof(res),"Camera"); case 44: { return weapon[0] = 0, strcat(weapon, "Night Vision Goggles", len), true; } case 45: { return weapon[0] = 0, strcat(weapon, "Thermal Goggles", len), true; } case 46: format(res,sizeof(res),"Parachute"); default: format(res,sizeof(res),"Unknown"); } return res; }
PHP код:
C:\Users\Nolan\Desktop\Pawn Scripting\gamemodes\Roleplayscript.pwn(1961) : error 035: argument type mismatch (argument 2)
C:\Users\Nolan\Desktop\Pawn Scripting\gamemodes\Roleplayscript.pwn(1961) : error 035: argument type mismatch (argument 2)
C:\Users\Nolan\Desktop\Pawn Scripting\gamemodes\Roleplayscript.pwn(2698) : warning 203: symbol is never used: "GunName"
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase
2 Errors.