help me pls with jail command
#1

pawn Код:
if(strcmp(cmd, "/jail", true) == 0){
if (adminlevel[playerid] < 2) return SendClientMessage(playerid,RED,"You Are Not Level 2 Admin!");
    new tmp2[256], time[3], date[3],name[20];
    new jailedname[MAX_PLAYER_NAME];
    new jailedid;
    new targetid = ReturnUser(tmp);
  gettime(time[0],time[1],time[2]);
  getdate(date[0],date[1],date[2]);

  tmp = strtok(cmdtext,idx);
  tmp2 = strtok(cmdtext,idx);
    new id = strval(tmp);
    new jtime = strval(tmp2);
if(!strlen(tmp) || !strlen(tmp2)) return SendClientMessage(playerid,ADMIN_RED,"[Usage:] /Jail [ID] [Time] [Reason]");
if(!IsPlayerConnected(id)) return SendClientMessage(playerid,ADMIN_RED,"[Error:] Invalid ID");
 GetPlayerName(id,name,sizeof(name));
    new result[128];
  result = strrest(cmdtext,idx);
if(!strlen(result)) return SendClientMessage(playerid,ADMIN_RED,"[Usage:] /Jail [ID] [Time] [Reason]");
  jail[targetid] = 1;
OnPlayerJailed(targetid);
GetPlayerName(playerid, sendername, sizeof(sendername));
GetPlayerName(jailedid, jailedname, sizeof(jailedname));
format(string,sizeof(string),"Administrator %s jailed %s. [ Time: %d ] [ Reson: %s - %d.%d.%d %d:%d:%d]",jtime,result,date[2],date[1],date[0],time[0],time[1],time[2]);
SendClientMessageToAll(COLOR_BLUE,string);
dini_IntSet(GetFile(playerid),"JTime",jtime);
dini_BoolSet(GetFile(playerid),"Jailed",true);
SetTimerEx("UnJail",jtime*1000*60,false,"%d",id);
format(string,sizeof(string),"~b~Time Left In Jail:%d",jtime);
GameTextForPlayer(id,string,1000,6);
return 1;}
the jail command is not working !
if i do /jail 0 5 testing it says unknown command
with this i cannot jail anyone !

Please someone help
any help is greatly appreciated !
Reply
#2

Use dcmd (much easyer/effectiver as strtok/strcmp), or zcmd, and put pawn script between [ pawn] and [/pawn] signs , AND where does it jail the player ? it doesnt set its positions/interriors to the jail. So the player wont be teleported to jail either.

Anyways this is a small peace of my old admin system for jail:

pawn Код:
if (!strcmp("/jail",cmd,true,5)) {
            new tmp[128],id;
            tmp=strtok(cmdtext,index);
            id=strval(tmp);
            if(!strlen(tmp) || !strlen(cmdtext[strlen(cmd)+strlen(tmp)+2]) || !IsNumeric(tmp)) {
                return SendClientMessage(playerid,COLOR_GREEN,"USAGE: /jail [playerid] [Reason]");
            }
            else if(!IsPlayerConnected(id)) {
                return SendClientMessage(playerid,COLOR_GREEN,"The Player is not connected");
            }
            else {
                new pName[32];
                new vName[32];
                GetPlayerName(playerid,pName,32);
                GetPlayerName(id,vName,32);
                SetPlayerInterior(id, 6);
                SetPlayerPos(id, 264.6288,77.5742,1001.0391);
                TogglePlayerControllable(id,0);
                format(string,sizeof string,"Administrator: %s Jailed %s(%i%). Reason: %s.",pName,vName,id,cmdtext[strlen(cmd)+strlen(tmp)+2]);
                SendClientMessageToAll(COLOR_GRAY,string);
            }
            return 1;
        }
Reply
#3

Use ZCMD and SSCANF much faster, cleaner, shorter.
Reply
#4

ya can u tell a jail and unjail command having a time [like jail id time reason ] with zcmd or sscanf ??
Reply
#5

Quote:
Originally Posted by James124
Посмотреть сообщение
ya can u tell a jail and unjail command having a time [like jail id time reason ] with zcmd or sscanf ??
First you will need the plugin/include for sscanf, i just learned dcmd (just like zcmd) and sscanf from some nice guys at the forums a while ago.

You can find my topic here, it explains everything:
https://sampforum.blast.hk/showthread.php?tid=168637

Theres all the info you need

Edit: I saw you changed your post, you dont have to use [ php][/php], use instead [ pawn][/pawn]
Reply
#6

i cant understand nothing from that !
Reply
#7

Quote:
Originally Posted by James124
Посмотреть сообщение
i cant understand nothing from that !
Search at tutorials, but anyways it dont has to be dcmd or zcmd, only its easyer.
It you still want to old the standard method is fine too! just look at my first post then.
Reply
#8

ok thx but can u make it with time ??
Reply
#9

Quote:
Originally Posted by James124
Посмотреть сообщение
ok thx but can u make it with time ??
Look at your own script and compare it, and check out how it gets/reads the time and experiment yourself. Thats the best way to learn it!
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)