Author Topic: Jail System  (Read 2488 times)

0 Members and 1 Guest are viewing this topic.

Offline kitt85711

  • Wiseguy
  • **
  • Posts: 72
    • View Profile
Jail System
« on: July 21, 2012, 05:32:28 pm »
I'm tired because I stayed up all night working on my script. But when I'm tired its like I don't give a damn and I just do it. I need a little help with this. I'm making a jail command for my cops N robbers server. And this idea is based on how Argonath's server jail system is. I'm kind of stuck and I get 26 errors and I want to find the source of the problem. So lets start.

I have

[pawn]new AutoJail[MAX_PLAYERS];
new IsJailed[MAX_PLAYERS];[/pawn]

At the top.

Now I have my command that starts it all.

[pawn]}
   else if ( strcmp( cmd, "jail", true ) == 0 )
   {
      new szMsg[ 128 ], plr;
      tmp = strtok( cmdtext, idx ), plr = FindPlayerIDFromString( tmp );
      if(PlayerInfo[playerid][Logged] != 1) SendClientMessage(playerid, COLOR_YELLOW, "*****You need to login first*****");
      else if(IsCop[playerid] == 0) SendClientMessage(playerid, COLOR_YELLOW,"*****Only Officers Of The Law Can Use This*****");
      else if (!strlen(tmp)) SendClientMessage(playerid,COLOR_RED,"USAGE: /c jail [Nick/ID]");
        else if(strcmp(GetPlayerLocation(playerid), "Vice-City-Prison-Washington-Beach-Vice-City-Beach", false) == 0) SendClientMessage(playerid, COLOR_YELLOW, "*****[Error]You have to be at the jail cells to jail someone!*****");
        else if(strcmp(GetPlayerLocation(plr), "Vice-City-Prison-Washington-Beach-Vice-City-Beach", false) == 0) SendClientMessage(playerid, COLOR_YELLOW, "*****[Error]%s has to be at the jail cells to be jailed!*****", gPlayers[playerid]);
      else if (IsCop[plr] == 1) SendClientMessage(playerid,COLOR_YELLOW,"*****[Error] %s Is A Cop!*****", gPlayers[playerid]);
       else if (plr == INACTIVE_PLAYER_ID) SendClientMessage(playerid,COLOR_YELLOW,"*****[Error] Unknown player*****");
      else if (IsCriminal[plr] == 0) SendClientMessage(playerid,COLOR_YELLOW,"*****[Error] >> %s << has not commited a crime!*****", gPlayers[playerid]);
       {
          format( szMsg, sizeof( szMsg ), "*****Officer >> %s << has jailed >> %s <<*****", gPlayers[ playerid ], gPlayers[ plr ]);
         SendClientMessageToAll( COLOR_YELLOW, szMsg );
         SetPlayerPos(plr,387.873, -509.743, 8.98706,0,0);
         (IsJailed [plr] = 1);
         TogglePlayerControllable(plr,0);
            RemovePlayerMarker(plr);
      }
      return 1;[/pawn]

I tried this one before but Stormeus was telling me about how you can't put timers on other people. So I thought it's just like a trap. Why not push them in and it works all by itself. So since they are jailed I'm telling the server they are and it should start the auto jail

My publics

[pawn]public OnPlayerJail(playerid)
{
if (IsJailed[playerid] == 1){
SetTimer("Jailed", 100000, 0);
GameTextForPlayer(playerid, "~w~Jailed", 60000,0,0);
AutoJail[playerid] = 1;
}
return 1;

}

public OnPlayerAutoJail(playerid)
{
AutoJail[playerid] = 1;
if (strcmp(GetPlayerLocation(playerid), "Vice-City-Prison-Washington-Beach-Vice-City-Beach", false) == 0){
SetTimer("AutoJail", 3000, 1);
}
if (AutoJail[playerid] == 0){
KillTimer("AutoJail");
return 1;

}
[/pawn]

And then I have my timers

[pawn]public Jailed( playerid )
{
   AutoJail[playerid] = 0;
   SendClientMessage(playerid, COLOR_YELLOW, "*****You have been released out of jail*****");
}

public AutoJail( playerid )
{
SetPlayerPos(playerid, 387.873, -509.743, 8.98706,0,0);
}[/pawn]

Is this not genius or what? :P heheh. Anyways I get these errors and I know on my public the if fails. I need something to put in that if.
Quote
if (strcmp(GetPlayerLocation(playerid), "Vice-City-Prison-Washington-Beach-Vice-City-Beach", false) == 0){

Offline aledark24

  • Made Man
  • ***
  • Posts: 206
  • I am a scripter and you have celous of me....so you crashed my servers
    • View Profile
Re: Jail System
« Reply #1 on: July 24, 2012, 07:08:35 am »
[pawn]else if (strcmp(cmd, "carcel", true) == 0) {
{
       new time[256],reason[256],plr;
      tmp = strtok(cmdtext, idx),plr = FindPlayerIDFromString(tmp),time = strtok(cmdtext, idx),reason = strtok(cmdtext, idx);

       if(Jail[plr] == 1) {
       SendClientMessage(playerid,NOTACCES,"Este Jugador Ya Esta Arrestado");
       }
       if(Jail[plr] == 0) {
      if (!strlen(tmp) || !strlen(time) || !strlen(reason)) SendClientMessage(playerid,COLOR_RED, "escribe: /c carcel [Nick] [Minutos] [Razon]");
        else if ( !IsAuthorized( playerid, "ahogar" ) ) SendClientMessage( playerid, COLOR_RED, "Tu no tienes Suficiente Nivel Para Usar Este Comando" );
      else if (plr == INACTIVE_PLAYER_ID) SendClientMessage(playerid,COLOR_RED,"Error: jugador desconocido");
      else {
            new string[256];
            SetPlayerRandomJailSpawns(plr);
            SetPlayerWeapon(plr,0,0);
            SetPlayerWeapon(plr,0,0);
            SetPlayerWeapon(plr,0,0);
            format(string,sizeof(string),"%s ha Arrestado a  %s Por %d Minutos",gPlayers[playerid],gPlayers[plr],strval(time));
            SendClientMessageToAll(COLOR_YELLOW, string);
            format(string,sizeof(string),"Razon:[ %s ].",cmdtext[strlen(tmp)+7]);
            SendClientMessageToAll(COLOR_YELLOW, string);
            SendClientMessage(plr,RED,"Tu has sido Arrestado");
            SetTimer("unjail",(strval(time)*60000),false);
            Jail[plr] = 1;
            TogglePlayerControllable(plr,0);
      }
      }
   
      }
      return 1;



   }
   else if(strcmp(cmd, "liberar", true) == 0) {
       {
       tmp = strtok(cmdtext, idx); new plr = FindPlayerIDFromString(tmp);
       if(Jail[plr] == 0) {
       SendClientMessage(playerid,NOTACCES,"Este Jugador a sido puesto en libertad");
       }
       if(Jail[plr] == 1) {
       if (!strlen(tmp)) SendClientMessage(playerid,COLOR_RED, "Escribe: /c liberar [Nick]");
         else if ( !IsAuthorized( playerid, "ahogar" ) ) SendClientMessage( playerid, COLOR_RED, "Tu no tienes Suficiente Nivel Para Usar Este Comando" );
       else{
           if (plr != INACTIVE_PLAYER_ID) {
               new string[256];
              format(string,sizeof(string),"%s ha Liberado a %s!",gPlayers[playerid],gPlayers[plr]);
            SendClientMessageToAll(COLOR_YELLOW, string);
            SetPlayerPos(plr,397.688, -471.821, 11.5172,0,0);
            SendClientMessage(plr,COLOR_YELLOW,"Tu Has Sido Liberado,No vuelvas a cometer delitos.!");
            Jail[plr] = 0;
            TogglePlayerControllable(plr,1);
         }
         else SendClientMessage(playerid,COLOR_RED,"Error: Jugador desconocido");
      }
      }
      }
      return 1;
                }[/pawn]

[pawn]new RandomPlayerJailSpawns[][playerjailspawns] = {
{387.0193,-510.2893,9.3956},
{388.4367,-511.6012,9.3956},
{389.7545,-509.8963,9.3956},
{388.2702,-508.7623,9.3956},
{389.5057,-507.1813,9.3956},
{390.9967,-508.3748,9.3956},
{392.1059,-506.9302,9.3956},
{390.8487,-505.9404,9.3956},
{392.1864,-504.1500,9.3956},
{393.5389,-505.2466,9.3956},
{395.1618,-504.3013,9.3956},
{382.1467,-505.1280,9.3956},
{384.9164,-502.2434,9.3956},
{387.6998,-499.4460,9.3956}
};

forward SetPlayerRandomJailSpawns(playerid);
forward unjail();[/pawn]

[pawn]#define NOTACCES 0xFF0000AA[/pawn]

[pawn]//==============================================================================
public SetPlayerRandomJailSpawns(playerid)

{
      new rand = random(sizeof(RandomPlayerJailSpawns));
      SetPlayerPos(playerid,RandomPlayerJailSpawns[rand][spawnxj],RandomPlayerJailSpawns[rand][spawnyj],RandomPlayerJailSpawns[rand][spawnzj],0,0); // Minigun
   return 1;
}
//==============================================================================
public unjail() {
    for(new i = 0; i < MAX_PLAYERS; i++) {
        if(IsPlayerConnected(i)) {
       if(Jail == 0) {
       }
       if(Jail == 1) {
            SetPlayerPos(i,397.688, -471.821, 11.5172,0,0);
            SendClientMessage(i,COLOR_YELLOW,"Has salido de la carcel, no vuelvas a cometer delitos!!");
            Jail = 0;
            TogglePlayerControllable(i,1);
      }
      }
      }
}
//==============================================================================[/pawn] so, you have more place to random jail :D
I am a great scripter and you are celous of my works
.....

Vice City Life Multiplayer By Saint

Offline kitt85711

  • Wiseguy
  • **
  • Posts: 72
    • View Profile
Re: Jail System
« Reply #2 on: July 24, 2012, 11:37:47 am »
Thanks but no thanks. I want to know how to fix my jail. I don't want to use Mobys because for one thing, it doesn't spawn me anywhere else but the jail cell, another thing is that I want to have most of my commands made by me. + Its in another language :P

Offline kitt85711

  • Wiseguy
  • **
  • Posts: 72
    • View Profile
Re: Jail System
« Reply #3 on: July 25, 2012, 07:11:34 am »
Can someone help me with such a code? I'm not sure how to fix the errors and what to put for
[pawn]if (strcmp(GetPlayerLocation(playerid), "Vice-City-Prison-Washington-Beach-Vice-City-Beach", false) == 0){[/pawn]