Help -
NTS - 05.08.2011
Hi, I would want to know how I can change these jail and un jail commands into zcmd to sscanf rather then strtok (please help):
Jail:
Код:
if(strcmp(cmd, "/jail", true) == 0)
{
new tmp2[256];
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_BRIGHTRED, "USAGE: /jail [playerid] [time]");
tmp2 = strtok(cmdtext, idx);
new money = strval(tmp2);
if(!strlen(tmp2)) return SendClientMessage(playerid, COLOR_BRIGHTRED, "USAGE: /jail [playerid] [time]");
new playa;
playa = ReturnUser(tmp);
if(PlayerInfo[playerid][pAdmin] < 2) return DenyMessage(playerid, 2);
if(!IsPlayerConnected(playa)) return SendClientMessage(playerid, COLOR_WHITE, "Invalid Player ID.");
if(PlayerInfo[playerid][pAdmin] < PlayerInfo[playa][pAdmin]) return SendClientMessage(playerid, COLOR_BRIGHTRED, "You can't jail a higher level Admin !");
if(playa != INVALID_PLAYER_ID)
{
PlayerInfo[playa][pPrisonTime] = money;
PlayerInfo[playa][pPrison] = 1;
GetPlayerName(playa, giveplayer, sizeof(giveplayer));
GetPlayerName(playerid, sendername, sizeof(sendername));
ResetPlayerWeapons(playa);
GameTextForPlayer(playa, "~r~Busted", 3000, 3);
SetPlayerInterior(playa, 3);
SetPlayerPos(playa, 198.5319,162.3093,1003.0300);
format(string, sizeof(string), "\"%s\" has been jailed by Admin \"%s\" for %d seconds.", giveplayer, sendername, money);
SendClientMessageToAll(COLOR_YELLOW, string);
SetTimerEx("UnJail",PlayerInfo[playa][pPrisonTime]*1000,0,"d",playa);
}
return 1;
UnJail:
Код:
if(strcmp(cmd, "/unjail", true) == 0)
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_BRIGHTRED, "USAGE: /unjail [playerid]");
new playa = ReturnUser(tmp);
if(PlayerInfo[playerid][pAdmin] < 2) return DenyMessage(playerid, 2);
if(!IsPlayerConnected(playa)) return SendClientMessage(playerid, COLOR_BRIGHTRED, "Invalid Player ID.");
if(playa != INVALID_PLAYER_ID)
{
GetPlayerName(playa, giveplayer, sizeof(giveplayer));
GetPlayerName(playerid, sendername, sizeof(sendername));
SetPlayerWorldBounds(playerid,20000.0000,-20000.0000,20000.0000,-20000.0000); //Reset world to player
SetPlayerInterior(playa, 0);
SetPlayerPos(playa, -1505.0958,1374.5413,3.9249);
format(string, sizeof(string), "\"%s\" has been un-jailed by Admin \"%s\".", giveplayer, sendername);
SendClientMessageToAll(COLOR_YELLOW, string);
}
return 1;
ThankYou
Re: Help -
Riddick94 - 05.08.2011
Here:
pawn Код:
#include "a_samp"
#include "zcmd"
#include "sscanf"
CMD:jail(playerid, params[])
{
new giveplayerid, time;
if(sscanf(params, "ud", giveplayerid, time))SendClientMessage(playerid, COLOR_WHITE, "USAGE: /jail [playerid] [time]");
if(PlayerInfo[playerid][pAdmin] < 2)return DenyMessage(playerid, 2);
if(!IsPlayerConnected(giveplayerid))return SendClientMessage(playerid, COLOR_WHITE, "Invalid Player ID.");
if(PlayerInfo[playerid][pAdmin] < PlayerInfo[giveplayerid][pAdmin])return SendClientMessage(playerid, COLOR_BRIGHTRED, "You can't jail a higher level Admin !");
else
{
PlayerInfo[giveplayerid][pPrisonTime] = money;
PlayerInfo[giveplayerid][pPrison] = 1;
GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
GetPlayerName(playerid, sendername, sizeof(sendername));
ResetPlayerWeapons(giveplayerid);
GameTextForPlayer(giveplayerid, "~r~Busted", 3000, 3);
SetPlayerInterior(giveplayerid, 3);
SetPlayerPos(giveplayerid, 198.5319,162.3093,1003.0300);
format(string, sizeof(string), "\"%s\" has been jailed by Admin \"%s\" for %d seconds.", giveplayer, sendername, money);
SendClientMessageToAll(COLOR_YELLOW, string);
SetTimerEx("UnJail",PlayerInfo[giveplayerid][pPrisonTime]*1000,0,"d",giveplayerid);
}
return true;
}
CMD:unjail(playerid, params[])
{
new giveplayerid;
if(sscanf(params, "u", giveplayerid))SendClientMessage(playerid, COLOR_WHITE, "USAGE: /unjail [playerid]");
if(PlayerInfo[playerid][pAdmin] < 2) return DenyMessage(playerid, 2);
if(!IsPlayerConnected(giveplayerid)) return SendClientMessage(playerid, COLOR_BRIGHTRED, "Invalid Player ID.");
else
{
GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
GetPlayerName(playerid, sendername, sizeof(sendername));
SetPlayerWorldBounds(playerid,20000.0000,-20000.0000,20000.0000,-20000.0000); //Reset world to player
SetPlayerInterior(giveplayerid, 0);
SetPlayerPos(giveplayerid, -1505.0958,1374.5413,3.9249);
format(string, sizeof(string), "\"%s\" has been un-jailed by Admin \"%s\".", giveplayer, sendername);
SendClientMessageToAll(COLOR_YELLOW, string);
}
return true;
}
Should work
Re: Help -
NTS - 05.08.2011
thanks mate