Need help with this Command[+rep] -
ZBits - 21.01.2013
Ok, so this command Works Good, no problem with it but i want to add something to it which i tired and it didnt work
Command is /jail [ID]
pawn Код:
COMMAND:jail(playerid, params[])
{
if(PlayerInfo[playerid][PlayerAdmin] <= JAIL_LEVEL) return SendClientMessage(playerid,COLOR_WHITE, "SERVER: Unknown command.");
new targetid;
if(sscanf(params,"u", targetid)) return SendClientMessage(playerid, COLOR_WHITE, ""WHITE"Usage: "GREEN"/jail "WHITE"[playerid]");
new ID = targetid;new string[128];
if(IsPlayerConnected(ID))
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(string,sizeof(string),"You have been Admin jailed by "SININE"%s",name);
SendClientMessage(ID,COLOR_SININE, string);
new rand = random(sizeof(RandomJail));
SetPlayerPos(ID, RandomJail[rand][0], RandomJail[rand][1], RandomJail[rand][2]);
ResetPlayerWeapons(ID);
SetPlayerInterior(ID, 3);
}
return 1;
}
I want to add "/jail [ID] [reason]" can you please help me on this?
Re: Need help with this Command[+rep] -
Dragonborn - 21.01.2013
Post the
strcmp line (or the full command). I want to see one thing before...
Re: Need help with this Command[+rep] -
ZBits - 21.01.2013
opps, i forgot to
here you go
pawn Код:
COMMAND:jail(playerid, params[])
{
if(PlayerInfo[playerid][PlayerAdmin] <= JAIL_LEVEL) return SendClientMessage(playerid,COLOR_WHITE, "SERVER: Unknown command.");
new targetid;
if(sscanf(params,"u", targetid)) return SendClientMessage(playerid, COLOR_WHITE, ""WHITE"Usage: "GREEN"/jail "WHITE"[playerid]");
new ID = targetid;new string[128];
if(IsPlayerConnected(ID))
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(string,sizeof(string),"You have been Admin jailed by "SININE"%s",name);
SendClientMessage(ID,COLOR_SININE, string);
new rand = random(sizeof(RandomJail));
SetPlayerPos(ID, RandomJail[rand][0], RandomJail[rand][1], RandomJail[rand][2]);
ResetPlayerWeapons(ID);
SetPlayerInterior(ID, 3);
}
return 1;
}
Didnt copy it all lol.
Re: Need help with this Command[+rep] -
LarzI - 21.01.2013
First of all indent your code. Second of all, if you'd read on the documentation on sscanf, you'd be able to easily do this yourself, however I will do it for you this time:
pawn Код:
COMMAND:jail(playerid, params[])
{
if(PlayerInfo[playerid][PlayerAdmin] <= JAIL_LEVEL) return SendClientMessage(playerid,COLOR_WHITE, "SERVER: Unknown command.");
new
ID,
reason[ 120 ]
;
if(sscanf(params,"uS[120]", ID, reason)) return SendClientMessage(playerid, COLOR_WHITE, ""WHITE"Usage: "GREEN"/jail "WHITE"[playerid] [reason(optional)]");
new string[128];
if(IsPlayerConnected(ID))
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(string,sizeof(string),"You have been Admin jailed by "SININE"%s%s%s",name, ( reason[0] ? (" Reason: ") : (""), reason );
SendClientMessage(ID,COLOR_SININE, string);
new rand = random(sizeof(RandomJail));
SetPlayerPos(ID, RandomJail[rand][0], RandomJail[rand][1], RandomJail[rand][2]);
ResetPlayerWeapons(ID);
SetPlayerInterior(ID, 3);
}
return 1;
}
Re: Need help with this Command[+rep] -
Jewell - 21.01.2013
pawn Код:
COMMAND:jail(playerid, params[])
{
if(PlayerInfo[playerid][PlayerAdmin] <= JAIL_LEVEL) return SendClientMessage(playerid,COLOR_WHITE, "SERVER: Unknown command.");
new targetid;
new reason[25];
if(sscanf(params,"us[25]", targetid,reason)) return SendClientMessage(playerid, COLOR_WHITE, "Usage: /jail [playerid] [reason]");
new ID = targetid;new string[128];
if(IsPlayerConnected(ID))
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(string,sizeof(string),"You have been Admin jailed by %s for %s",name, reason);
SendClientMessage(ID,COLOR_SININE, string);
new rand = random(sizeof(RandomJail));
SetPlayerPos(ID, RandomJail[rand][0], RandomJail[rand][1], RandomJail[rand][2]);
ResetPlayerWeapons(ID);
SetPlayerInterior(ID, 3);
return 1;
}
else return SendClientMessage(playerid,COLOR_SININE, "player is not connected.");
}
Re: Need help with this Command[+rep] -
batonsa - 21.01.2013
if you are trying to add this to your gamemode, you need zcmd include, if you are using strcmp then u need to convert it.