Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - · KaTaNNa ·

Pages: [1]
1
mIRC/pawn Scripting / I have a problem
« on: January 05, 2013, 12:37:18 am »
Hi all, here is my cmd. apparently the server fails to function, or nose if I'm the bad scripter.
get to the point, I want the server to deliver $ 100 to 2 players from different teams randomly.
example: pedro (Team X): get $ 100 from the server.
example: guy (and team) receives $ 100 from the server.
That's what I want to do the server

[pawn]else if ( strcmp( cmd, "cashazar", true ) == 0 )
   {         
      if ( !IsLoggedIn( playerid ) ) SendClientMessage( playerid, COLOR_RED, "Por favor,conectate en tu cuenta!" );
      else if ( !IsAuthorized( playerid, cmd ) ) SendClientMessage( playerid, COLOR_RED, "Tu no tienes acceso a este comando!" );      
      else
      {      
         format( szMsg, 256, "Admin [%s] starting Cash Azar", gPlayers[ playerid ]);
         SendClientMessageToAll( GREEN, szMsg );                     
         new m = GetMaxPlayers() + 1;   
         for(new i = 0; i < m; i++) {
        if (IsPlayerConnected(i)) {
   if(GetPlayerTeam(random(m)) == 15) {
   format(szMsg,256,"[%s] the leader of your team receives $100.",gPlayers[ random(m) ]);
   SendClientMessageToAll(BLUE, szMsg);
   IncPlayerHandCash(random(m),100);   
   }
   else if(GetPlayerTeam(random(m)) == 11) {
   format(szMsg,256,"[%s] the leader of your team receives $100.",gPlayers[ random(m) ]);
   SendClientMessageToAll(COLOR_YELLOW, szMsg);
   IncPlayerHandCash(random(m),100);   
  }      
  }
  }
  }      
   return 1;
   }[/pawn]

2
Hello and Merry Christmas to all the team members and the forum. Today I bring you a cmd to buy a phone and talk, saved in your system registry.

Well this is the '/ c buycell' :

[pawn]else if ( strcmp( cmd, "buycell", true ) == 0 )
   {      
      new cash = GetPlayerMoney(playerid);      
      if (GetPlayerCel(playerid) == 1) {
    SendClientMessage(playerid, GREEN,"You already have a telefono.Solo use it /c cell.");
    }
    if (GetPlayerCel(playerid) == 0) {
      if ( !IsLoggedIn( playerid ) ) SendClientMessage( playerid, COLOR_RED, "Please login to your account!" );            
      else if(cash < 200) {
      format( szMsg, sizeof( szMsg ), "Necesita :($%d) mas para comprar un telefono.",200 - cash);   
         SendClientMessage( playerid, COLOR_YELLOW, szMsg );
  }      
      else if (!PlayerIsArea(6, playerid, 351.2946, 1110.8674, 25.3879)) SendClientMessage( playerid, COLOR_RED, "CountDown Head to the Mall!" );   
      else
      {
         IncPlayerCel(playerid,1);
         SendClientMessage(playerid,COLOR_YELLOW,"You bought a Cellphone.Cost $200.Now use it with /c cell.");
         DecPlayerHandCash(playerid,200);
      }      
      }      
      return 1;
   }   [/pawn]

Now the '/c cell' :

[pawn]else if ( strcmp( cmd, "cell", true ) == 0 )
   {
      new plr;      
      tmp = strtok( cmdtext, idx ), plr = FindPlayerIDFromString( tmp );
      if (GetPlayerCel(playerid) == 0) {
    SendClientMessage(playerid, GREEN,"You do not have a phone. Buy it with /c buycell.");
    }
    if (GetPlayerCel(playerid) == 1) {
      if ( !IsLoggedIn( playerid ) ) SendClientMessage( playerid, COLOR_RED, "Please login to your account!" );      
      else if ( !strlen( tmp ) ) SendClientMessage( playerid, COLOR_GREEN, "Type: /c cell [Nick/ID] [Message]" );
      else if ( plr == INACTIVE_PLAYER_ID ) SendClientMessage( playerid, COLOR_RED, "Error: Unknown player." );         
      else
      {      
         format( szMsg, sizeof( szMsg ), "Flames by cellphone to [%s] : (%s)", gPlayers[ plr ], cmdtext[strlen(tmp)+4]);
         SendClientMessage( playerid, GREEN, szMsg );
         format( szMsg, sizeof( szMsg ), "Calling you [%s] : (%s)", gPlayers[ playerid ], cmdtext[strlen(tmp)+4]);
         SendClientMessage( plr, GREEN, szMsg );      
      }      
      }      
      return 1;
   }[/pawn]

Those are the cmds, now we need to define a few things :

[pawn]new INFO[256];//This would be near the beginning of "gm"[/pawn]

[pawn]stock PlayerIsArea(Float:radi, playerid, Float:x, Float:y, Float:z)
{
    if(IsPlayerConnected(playerid))
   {
      new Float:oldposx, Float:oldposy, Float:oldposz;
      new Float:tempposx, Float:tempposy, Float:tempposz;
      GetPlayerPos(playerid, oldposx, oldposy, oldposz);
      tempposx = (oldposx -x);
      tempposy = (oldposy -y);
      tempposz = (oldposz -z);
      if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
      {
         return 1;
      }
   }
   return 0;
}[/pawn]

[pawn]public GetPlayerCel(playerid)
{
format(INFO,256, USERS_FILE, gPlayers[playerid]);
   new tel = dini_Int(INFO,"Cellphone");
   return tel;
}[/pawn]

[pawn]public IncPlayerCel(playerid,amount)
{
    format(INFO,256, USERS_FILE, gPlayers[playerid]);
   dini_IntSet(INFO,"Cellphone", GetPlayerTel(playerid)+amount);
}[/pawn]

That's it. I hope you liked it and served .

Pages: [1]