Please help me to fix those commands -
Strier - 03.02.2013
pawn Код:
CMD:giveallweapon(playerid,params[])
{
if(PlayerInfo[playerid][Level] >= 4)
{
new tmp[256], tmp2[256], tmp3[256], Index; tmp = strtok(params,Index), tmp2 = strtok(params,Index), tmp3 = strtok(params,Index);
if(isnull(tmp) || isnull(tmp2)) return SendClientMessage(playerid, red, "USAGE: /giveweapon [playerid] [weapon id/weapon name] [ammo]");
new Weap, ammo, WeapName1[32], string[128];
if(!strlen(tmp3) || !IsNumeric(tmp3) || strval(tmp3) <= 0 || strval(tmp3) > 99999) ammo = 500; else ammo = strval(tmp3);
if(Weap == 38 || Weap == 36) return SP red, "You cannot give those weapons!");
if(!IsNumeric(tmp2)) Weap = GetWeaponIDFromName(tmp2); else Weap = strval(tmp2);
if(!IsValidWeapon(Weap)) return SendClientMessage(playerid,red,"ERROR: Invalid weapon ID");
CMDMessageToAdmins(playerid,"GIVEALLWEAPON");
GetWeaponName(Weap,WeapName1,32);
format(string,sizeof(string),"Administrator %s has given all players weapon: %s (%d) with %d ammo",WeapName1,Weap,ammo);
SendClientMessage(playerid, blue, string);
}return GivePlayerWeapon(playerid, WeapName1, Weap, ammo);
}else return SP, red, "You need to be level 4+ to use this command");
}
Ok... so i tried to fix GiveAllweapon command by default by ladmin, so it can give all the players a weapon by the weapon name...
Errors:
pawn Код:
C:\Users\Guille\Desktop\Samp scripting\Server23\Server\gamemodes\TD.pwn(13673) : error 035: argument type mismatch (argument 2)
C:\Users\Guille\Desktop\Samp scripting\Server23\Server\gamemodes\TD.pwn(13674) : error 010: invalid function or declaration
Lines:
pawn Код:
if(isnull(tmp) || isnull(tmp2)) return SendClientMessage(playerid, red, "USAGE: /giveweapon [playerid] [weapon id/weapon name] [ammo]");
new Weap, ammo, WeapName1[32], string[128];
But if i remove WeapName1 from the new it gives me another errors...
pawn Код:
C:\Users\Guille\Desktop\Samp scripting\Server23\Server\gamemodes\TD.pwn(13670) : error 048: array dimensions do not match
C:\Users\Guille\Desktop\Samp scripting\Server23\Server\gamemodes\TD.pwn(13673) : error 035: argument type mismatch (argument 2)
C:\Users\Guille\Desktop\Samp scripting\Server23\Server\gamemodes\TD.pwn(13674) : error 010: invalid function or declaration
Thank you for reading this.
Respuesta: Command help.. -
Strier - 04.02.2013
pawn Код:
CMD:heal(playerid, params[])
{
foreach(Player,i)
{
if(gTeam[i] == gTeam[playerid])
{
if(gClass[playerid] != CLASS_SNIPER) return SP red, "You need to be Sniper(Rank"#SNIPER_RANK") to use this command");
{
if(heal_timer[playerid] > 0) return SP COLOR_RED, "[ERROR]: You need to wait for 25 seconds to use this command again");
heal_timer[playerid] = heal_time;
new targetid, str[50], str2[50], id;
if(sscanf(params, "uu", targetid, id)) return SendClientMessage(playerid, -1 , "You cannot heal yourself");
if(isnull(params)) return SendClientMessage(playerid, 0xFFFFFFF,"Usage: /heal [Player id]");
if(playerid == id) return SendClientMessage(playerid, red, "You cannot heal your self.");
if(!IsPlayerConnected(targetid)) return SP red, "The id you're looking for seems not to be online");
SetPlayerHealth(playerid, 100);
format(str, sizeof(str), "Sniper %s has healed you", GetName(playerid));
SendClientMessage(targetid, COLOR_LIMEGREEN, str);
format(str2, sizeof(str2), "You have healed %s he might be thankful to you now", GetName(targetid));
SendClientMessage(playerid, COLOR_LIMEGREEN, str2);
}
}else return SendClientMessage(playerid, red, "This player is not in your team");
}
return 1;
}
Also this.. it gives no errors at all.. but I can't use it in Game, i've made a timer to prevent the player from using it if 60 seconds have not passed, but there is a problem, and it's with sscanf if someone could tell me how to fix it please.... Help will be very appreciated. thanks
Re: Command help.. -
lean1337 - 04.02.2013
CMD:heal(playerid, params[])
{
foreach(Player,i)
{
new targetid, str[50], str2[50], id;
if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, -1 , "You cannot heal yourself");
if(isnull(params)) return SendClientMessage(playerid, 0xFFFFFFF,"Usage: /heal [Player id]");
if(playerid == id) return SendClientMessage(playerid, -1, "You cannot heal your self.");
if(!IsPlayerConnected(targetid)) return SendClientMessage (playerid, -1, "The id you're looking for seems not to be online");
SetPlayerHealth(targetid, 100);
format(str, sizeof(str), "Sniper has healed you");
SendClientMessage(targetid, -1, str);
format(str2, sizeof(str2), "You have healed he might be thankful to you now");
SendClientMessage(playerid, -1, str2);
}
return 1;
}
This one works, just add the if stuff to it, tested ig aswell.