how to make a cmd views params and no params! - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: how to make a cmd views params and no params! (
/showthread.php?tid=522340)
how to make a cmd views params and no params! -
KillerStrike23 - 27.06.2014
hello I had created this saving skin cmd but I need to make it if player doesn't put any params like only cmd /skin it will force him to class selection but if player used skin numbers it will save him the skin!
my code
pawn Код:
CMD:skin(playerid,params[]) {
if(PlayerInfo[playerid][LoggedIn] == 1) {
if(isnull(params)) {
new SkinID = strval(params);
if(SkinID < 299) {
dUserSetINT(PlayerName2(playerid)).("FavSkin",SkinID);
dUserSetINT(PlayerName2(playerid)).("UseSkin",1);
SetPlayerSkin(playerid,SkinID);
} else SendClientMessage(playerid,0xFF0000AA,"error: Available Skins: 0 - 299 !");
} else SendClientMessage(playerid,red,"ERROR: You must be logged in to use this command");
return 1;}
Force Class
pawn Код:
if(PlayerInfo[playerid][Jailed] == 1) return SendClientMessage(playerid,COLOR_BRIGHTRED,"You cannot escape your punishment!");
SetPlayerHealth(playerid, 0.0);
ForceClassSelection(playerid);
if(IsPlayerInAnyVehicle(playerid)) {
if(VehicleInfo[GetPlayerVehicleID(playerid)][Temp] == 1) SetTimerEx("EraseVehicle", 5000,0,"i",GetPlayerVehicleID(playerid));}
Re: how to make a cmd views params and no params! -
Threshold - 27.06.2014
pawn Код:
CMD:skin(playerid,params[])
{
if(!PlayerInfo[playerid][LoggedIn]) return SendClientMessage(playerid, red, "ERROR: You must be logged in to use this command");
if(params[0] == EOS) return SendClientMessage(playerid, red, "USAGE: /skin [skin id]");
new skin = strval(params);
if(!(-1 < skin < 300)) return SendClientMessage(playerid, red, "ERROR: Available Skins: 0 - 299 !");
dUserSetINT(PlayerName2(playerid)).("FavSkin", skin);
dUserSetINT(PlayerName2(playerid)).("UseSkin", 1);
SetPlayerSkin(playerid, skin);
return 1;
}
'if(params[0] == EOS)' checks if the string 'params' is empty or not.
pawn Код:
ForceClassSelection(playerid);
SetPlayerHealth(playerid, 0.0);
'ForceClassSelection' must be called BEFORE the player dies/respawns. Otherwise it will only take effect after the next death/respawn
Re: how to make a cmd views params and no params! - Emmet_ - 27.06.2014
Your usage of "isnull" is incorrect. Try:
pawn Код:
CMD:skin(playerid,params[]) {
if(PlayerInfo[playerid][LoggedIn] == 1) {
if(!isnull(params)) {
new SkinID = strval(params);
if(SkinID < 299) {
dUserSetINT(PlayerName2(playerid)).("FavSkin",SkinID);
dUserSetINT(PlayerName2(playerid)).("UseSkin",1);
SetPlayerSkin(playerid,SkinID);
} else SendClientMessage(playerid,0xFF0000AA,"error: Available Skins: 0 - 299 !");
} else SendClientMessage(playerid,red,"ERROR: You must be logged in to use this command");
return 1;
}
Re: how to make a cmd views params and no params! -
Threshold - 27.06.2014
Quote:
Originally Posted by Emmet_
Your usage of "isnull" is incorrect.
|
And he missed a bracket