if(!strcmp(option, "health", true))
{
new Float:hp;
if(sscanf(params, "s[10]f", option, hp)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /seteventinfo health [amount]");
EventHealth = hp;
SendClientMessage(playerid, COLOR_LIGHTBLUE, "You have set the new event health amount.");
return 1;
}
if(!strcmp(option, "armour", true))
{
new Float:ap;
if(sscanf(params[6], "s[10]f", option, ap)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /seteventinfo armour [amount]");
EventArmour = ap;
SendClientMessage(playerid, COLOR_LIGHTBLUE, "You have set the new event armour amount.");
return 1;
}
if(!strcmp(option, "weapon", true))
{
new slot, weaponid, ammo;
if(sscanf(params, "s[10]iii", option, slot, weaponid, ammo)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /seteventinfo weapon [slot] [weapon] [ammo]");
if(slot < 1 || slot > 3) return SendClientMessage(playerid, COLOR_GREY, "Slots are between 1 to 3.");
if(GetWeaponSlot(weaponid) == -1) return SendClientMessage(playerid, COLOR_WHITE, "Invalid weapon ID.");
if(ammo < 1) return SendClientMessage(playerid, COLOR_GREY, "Ammo must be 1 or higher.");
new string[128], weaponname[32];
EventWeapon[slot--] = weaponid;
EventAmmo[slot--] = ammo;
GetWeaponName(weaponid, weaponname, sizeof(weaponname));
format(string, sizeof(string), "You have set the %d event weapon slot to %s with %d bullets.", slot, weaponname, ammo);
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
return 1;
}
if(!strcmp(option, "text", true))
{
new text[80];
if(sscanf(params, "s[10]s[80]", option, text)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /seteventinfo text [text]");
format(EventText, sizeof(EventText), "~r~%s", text);
SendClientMessage(playerid, COLOR_LIGHTBLUE, "You have set the joining event game text.");
return 1;
}
Can you show me the creation of variable 'option'?
+ 'params[6]' - whats that for? |
CMD:seteventinfo(playerid, params[])
{
if(!IsAllowed(playerid, 3)) return NoAuth(playerid);
new option[32];
if(sscanf(params, "s[10]", option))
{
SendClientMessage(playerid, COLOR_WHITE, "UASGE: /seteventinfo [option]");
SendClientMessage(playerid, COLOR_GREY, "Available Options: Health || Armour || Weapon || Position || Text");
return 1;
}
params[6] is a tip someone told me to do on the forums, didn't really work so I removed it, forgot to remove it from the armour parameter
Here is the option var PHP код:
|
Match the 'option' string size with all the parameters below. (ex. if you've assigned 10 cells, change the [32] to [10])
|
/seteventinfo health
/seteventinfo health 100
[CMD] [SaP]Ne[X]oR[R]dT: /seteventinfo health [CMD] [SaP]Ne[X]oR[R]dT: /seteventinfo health 100 sscanf warning: String buffer overflow.
if(sscanf(params, "s[32]", option))
{
CMD:seteventinfo(playerid, params[])
{
if(!IsAllowed(playerid, 3)) return NoAuth(playerid);
if(isnull(params))
{
SendClientMessage(playerid, COLOR_WHITE, "UASGE: /seteventinfo [option]");
SendClientMessage(playerid, COLOR_GREY, "Available Options: Health || Armour || Weapon || Position || Text");
return 1;
}
if (!strcmp(params, "health", true, 6))
{
if (params[6] != ' ' && params[6] != 0)
{
SendClientMessage(playerid, COLOR_WHITE, "UASGE: /seteventinfo [option]");
SendClientMessage(playerid, COLOR_GREY, "Available Options: Health || Armour || Weapon || Position || Text");
return 1;
}
new Float:hp;
if (sscanf(params[7], "f", hp))
return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /seteventinfo health [amount]");
EventHealth = hp;
SendClientMessage(playerid, COLOR_LIGHTBLUE, "You have set the new event health amount.");
return 1;
}
if (!strcmp(params, "text", true, 4))
{
if (params[4] != ' ' && params[4] != 0)
{
SendClientMessage(playerid, COLOR_WHITE, "UASGE: /seteventinfo [option]");
SendClientMessage(playerid, COLOR_GREY, "Available Options: Health || Armour || Weapon || Position || Text");
return 1;
}
new text[80];
if (sscanf(params[5], "s[80]", text)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /seteventinfo text [text]");
format(EventText, sizeof(EventText), "~r~%s", text);
SendClientMessage(playerid, COLOR_LIGHTBLUE, "You have set the joining event game text.");
return 1;
}
/*
if (!strcmp(params, "[OPTION]", true, LENGTH OF OPTION))
{
if (params[LENGTH OF OPTION] != ' ' && params[LENGTH OF OPTION] != 0)
{
SendClientMessage(playerid, COLOR_WHITE, "UASGE: /seteventinfo [option]");
SendClientMessage(playerid, COLOR_GREY, "Available Options: Health || Armour || Weapon || Position || Text");
return 1;
}
Use params[LENGTH OF OPTION + 1] in sscanf
}
*/
return 1;
}
CMD:set(playerid, params[])
{
if(pAccount[playerid][pAdmin] < ADMIN) return ErrorMsg(playerid, false);
new
parameter[30 + '\0'],
scmd[50]; // scmd = subcmd
if(sscanf(params, "s[30]S()[130]", parameter, scmd)) return SCM(playerid, LBLUE, "/set [money - score - kills - death - skin - vhp - hp - armor - v(irtual)w(orld) - int(erior)]");
if(!strcmp(parameter, "money"))
{
if(pAccount[playerid][pAdmin] < SADMIN) return ErrorMsg(playerid, false);
new cible,
money;
if(sscanf(scmd, "ui", cible, money)) return SCM(playerid, LBLUE, "/set money [playerid/name] [montant]");
if(!IsPlayerConnected(cible))
return ErrorMsg(playerid, _, "Cette personne n'est pas connectйe.");
ResetPlayerMoney(playerid);
GivePlayerMoney(cible, money);
pAccount[cible][pMoney] = money;
SaveSpecificPlayerStats(playerid, 4);
if(money > 0)
return InfoAnnonce(cible, "%i$ on йtй crйditйs sur votre agent de poche.", money);
else
return InfoAnnonce(cible, "%i$ ont йtй retirйs de votre argent de poche.", 0-money);
}
else if(!strcmp(parameter, "score"))
{
new cible,
score;
if(pAccount[playerid][pAdmin] < SADMIN) return ErrorMsg(playerid, false);
if(sscanf(scmd, "ui", cible, score)) return SCM(playerid, LBLUE, "/set score [playerid/name] [montant]");
if(!IsPlayerConnected(cible))
return ErrorMsg(playerid, _, "Cette personne n'est pas connectйe.");
SetPlayerScore(cible, GetPlayerScore(cible) + score);
pAccount[cible][pScore] = score;
if(score > 0)
return InfoAnnonce(cible, "Un administrateur a ajoutй %i а votre score.", score);
else
return InfoAnnonce(cible, "Un administrateur a retirй %i а votre score.", score);
}
else if(!strcmp(parameter, "kills"))
{
new cible,
kills;
if(pAccount[playerid][pAdmin] < SADMIN) return ErrorMsg(playerid, false);
if(sscanf(scmd, "ui", cible, kills)) return SCM(playerid, LBLUE, "/set kills [playerid/name] [montant]");
if(!IsPlayerConnected(cible))
return ErrorMsg(playerid, _, "Cette personne n'est pas connectйe.");
pAccount[cible][pKills] += kills;
if(kills > 0)
return InfoAnnonce(cible, "Un administrateur a ajoutй %i kills а vos statistiques.", kills);
else
return InfoAnnonce(cible, "Un administrateur a retirй %i kills de vos statistiques.", kills);
}
else if(!strcmp(parameter, "death"))
{
new cible,
death;
if(pAccount[playerid][pAdmin] < SADMIN) return ErrorMsg(playerid, false);
if(sscanf(scmd, "ui", cible, death)) return SCM(playerid, LBLUE, "/set death [playerid/name] [montant]");
if(!IsPlayerConnected(cible))
return ErrorMsg(playerid, _, "Cette personne n'est pas connectйe.");
pAccount[cible][pDeath] += death;
if(death > 0)
return InfoAnnonce(cible, "Un administrateur a ajoutй %i morts а vos statistiques.", death);
else
return InfoAnnonce(cible, "Un administrateur a retirй %i morts de vos statistiques.", death);
}
else if(!strcmp(parameter, "skin"))
{
new cible,
skin;
if(pAccount[playerid][pAdmin] < MODO) return ErrorMsg(playerid, false);
if(sscanf(scmd, "ui", cible, skin)) return SCM(playerid, LBLUE, "/set skin [playerid/name] [Skinid]");
if(!IsPlayerConnected(cible))
return ErrorMsg(playerid, _, "Cette personne n'est pas connectйe.");
if(skin < 0 || skin > 311)
return ErrorMsg(playerid, _, "Skin invalide! [0-311]");
pAccount[cible][pSkin] = skin;
SetPlayerSkin(cible, skin);
return InfoAnnonce(cible, "Votre skin a йtй changй par un administrateur (ID: %i).", skin);
}
else if(!strcmp(parameter, "hp") || !strcmp(parameter, "health"))
{
new cible,
Float:health;
if(pAccount[playerid][pAdmin] < ADMIN) return ErrorMsg(playerid, false);
if(sscanf(scmd, "if", cible, health)) return SCM(playerid, LBLUE, "/set hp [playerid] [vie]");
if(!IsPlayerConnected(cible))
return ErrorMsg(playerid, _, "Cette personne n'est pas connectйe.");
SetPlayerHealth(cible, health);
pAccount[cible][pHealth] = health;
SaveSpecificPlayerStats(playerid, 8);
AdminMessage(playerid, "Vous avez changй les HP (%0.2f) de %s.", health, GetName(cible, true));
InfoAnnonce(cible, "Vos points de vies ont йtй changйs par un administrateur.");
return 1;
}
else if(!strcmp(parameter, "armor") || !strcmp(parameter, "ar"))
{
new cible,
Float:armor;
if(pAccount[playerid][pAdmin] < ADMIN) return ErrorMsg(playerid, false);
if(sscanf(scmd, "if", cible, armor)) return SCM(playerid, LBLUE, "/set armor [playerid] [armure]");
if(!IsPlayerConnected(cible))
return ErrorMsg(playerid, _, "Cette personne n'est pas connectйe.");
SetPlayerArmour(cible, armor);
pAccount[cible][pArmor] = armor;
AdminMessage(playerid, "Vous avez changй l'armure (%0.2f) de %s.", armor, GetName(cible, true));
InfoAnnonce(cible, "Vos points d'armure ont йtй changйs par un administrateur.");
return 1;
}
else if(!strcmp(parameter, "vhp"))
{
new vehicleid,
Float:health;
if(pAccount[playerid][pAdmin] < SADMIN) return ErrorMsg(playerid, false);
if(sscanf(scmd, "if", vehicleid, health)) return SCM(playerid, LBLUE, "/set vhp [vehicleid] [health]");
if(!IsValidVehicle(vehicleid))
return ErrorMsg(playerid, _, "Ce vйhicule est invalide.");
SetVehicleHealth(vehicleid, health);
vStats[vehicleid][vHealth] = health;
AdminMessage(playerid, "Vous avez changй les HP (%0.2f) du vйhicule %i.", health, vehicleid);
AdminCmd("%s a changй les HP (%0.2f) du vйhicule portant l'ID %i", GetName(playerid), health, vehicleid);
return 1;
}
else if(!strcmp(parameter, "vw") || (!strcmp(parameter, "virtualworld")))
{
new cible,
vw;
if(pAccount[playerid][pAdmin] < ADMIN) return ErrorMsg(playerid, false);
if(sscanf(scmd, "ui", cible, vw)) return SCM(playerid, LBLUE, "/set v(irtual)w(orld) [playerid/nom] [id du monde virtuel]");
if(!IsPlayerConnected(cible))
return ErrorMsg(playerid, _, "Cette personne n'est pas connectйe.");
SetPlayerVirtualWorld(cible, vw);
pAccount[cible][pVirtualWorld] = vw;
AdminMessage(playerid, "Vous avez changй le monde virtuel de %s par %i.", GetName(cible, true), vw);
InfoAnnonce(cible, "Votre monde virtuel a йtй changй par un administrateur.");
return 1;
}
else if(!strcmp(parameter, "int") || (!strcmp(parameter, "interior")))
{
new cible,
int;
if(pAccount[playerid][pAdmin] < ADMIN) return ErrorMsg(playerid, false);
if(sscanf(scmd, "ui", cible, int)) return SCM(playerid, LBLUE, "/set int(erior) [playerid/nom] [id de l'intйrieur]");
if(!IsPlayerConnected(cible))
return ErrorMsg(playerid, _, "Cette personne n'est pas connectйe.");
SetPlayerVirtualWorld(cible, int);
pAccount[cible][pInterior] = int;
AdminMessage(playerid, "Vous avez changй l'intйrieur de %s par %i.", GetName(cible, true), int);
InfoAnnonce(cible, "L'ID de votre intйrieur a йtй changй par un administrateur.");
return 1;
}
else return ErrorMsg(playerid, _, "Paramйtre introuvable.");
}