Szerző Téma: Givecash parancs.  (Megtekintve 1712 alkalommal)

Penzykee.

  • Vendég
Givecash parancs.
« Dátum: 2011. Március 14. - 15:13:41 »
0 Show voters
Hali.
Nekem egy olyan script kéne amivel pénzt tudok küldeni a másiknak.
Nem találtam a fórumon.
Válaszokat elõre is kösz!

Nem elérhető SoAP

  • 182
    • Profil megtekintése
Givecash parancs.
« Válasz #1 Dátum: 2011. Március 14. - 15:26:09 »
0 Show voters
Tessék:
 
#include <a_samp>
#include <sscanf2>
#include <zcmd>
 
public OnFilterScriptInit()
{
print(\"\\n--------------------------------------\");
print(\" Blank Filterscript by your name here\");
print(\"--------------------------------------\\n\");
return 1;
}
public OnFilterScriptExit()
{
return 1;
}
CMD:givecash(playerid, params[])
{
new GiveID, osszeg;
if(sscanf(params, \"ui\", GiveID, osszeg))
{
    SendClientMessage(playerid, 0xB4B5B7FF, \"Használat: /givecash [id] [összeg]\");
    return 1;
}
if(GiveID == INVALID_PLAYER_ID) return SendClientMessage(playerid, 0xB4B5B7FF, \"Rossz ID!\");
if(!IsPlayerConnected(GiveID) && IsPlayerNPC(GiveID)) return SendClientMessage(playerid, 0xB4B5B7FF, \"Rossz ID!\");
if(IsPlayerAdmin(playerid))
{
   GivePlayerMoney(GiveID, osszeg);
}
else return SendClientMessage(playerid, 0xB4B5B7FF, \"Nem vagy RCON admin!\");
return 1;
}
« Utoljára szerkesztve: 2011. Március 14. - 15:28:27 írta SoAP »

Penzykee.

  • Vendég
Givecash parancs.
« Válasz #2 Dátum: 2011. Március 14. - 15:29:32 »
0 Show voters
Nem lehetne kihagyni a zcmd-t és a sscanf2-t?

Nem elérhető SoAP

  • 182
    • Profil megtekintése
Givecash parancs.
« Válasz #3 Dátum: 2011. Március 14. - 15:31:25 »
0 Show voters
Hát ha valaki átírja neked oké. De én eleve zcmd + sscanf módszert tanultam (Hála ScreaM nek :D). Szóval másképp nem nagyon tudom neked megoldani.

Penzykee.

  • Vendég
Givecash parancs.
« Válasz #4 Dátum: 2011. Március 14. - 15:33:12 »
0 Show voters
Ok, akkor várok. XD

Nem elérhető Csabesz

  • 7827
    • Profil megtekintése
Givecash parancs.
« Válasz #5 Dátum: 2011. Március 14. - 16:23:55 »
0 Show voters
Én találtam egyet:
 

#include \"a_samp\"
#define COLOR_TAN         0xFFFFCCAA
#define COLOR_RED         0xAA3333AA
#define COLOR_GREEN       0x33AA33AA
public OnFilterScriptInit( )
{
print(\"GiveCash szkript[FS].\");
print(\"         Írta:       \");
print(\"      Sp33Ðy_Wq£f    \");
return 1;
}
public OnPlayerConnect( playerid ) return SendClientMessage(playerid,COLOR_TAN,\"GiveCash betöltve: /givecash [iD] (Összeg)\"),1;
public OnPlayerCommandText( playerid , cmdtext[] )
{
new idx;
new gid;
new money;
new kj[24];
new pn[24];
new str[60];
new cmd[256];
cmd = strtok(cmdtext, idx);
if(strcmp(cmd,\"/givecash\", true) == 0)
{
cmd = strtok(cmdtext, idx);
if(!strlen(cmd)) return SendClientMessage(playerid,COLOR_TAN,\"Használat: /givecash [iD] (Összeg)\"),1;
gid = strval(cmd);
cmd = strtok(cmdtext, idx);
if(!strlen(cmd)) return SendClientMessage(playerid,COLOR_TAN,\"Használat: /givecash [iD] (Összeg)\"),1;
money = strval(cmd);
if(GetPlayerMoney(playerid) < 0) return SendClientMessage(playerid,COLOR_RED,\"Nincs elég összeg nálad!!\"),1;
if(playerid == gid) return SendClientMessage(playerid,COLOR_RED,\"Magadnak nem utalhatsz!!\");
if(IsPlayerConnected(gid))
{
    GetPlayerName(playerid,pn,sizeof(pn));
    GetPlayerName(gid,kj,sizeof(kj));
    format(str,sizeof(str),\"Utaltál %s-nek(nak( $%d-t.\", kj , money );
    SendClientMessage(playerid,COLOR_GREEN, str);
    format(str,sizeof(str),\"%s Utalt neked $%d-t.\", pn , money );
    SendClientMessage(gid,COLOR_GREEN, str);
GivePlayerMoney(playerid,GetPlayerMoney(playerid)-money);
GivePlayerMoney(gid,money);
return 1;
}
else SendClientMessage(playerid,COLOR_RED,\"Érvénytelen ID!!\");
return 1;
}
return 0;
}
 
public OnFilterScriptExit( ) return 1;
strtok(const string[], &index)
{
new length = strlen(string);
while ((index < length) && (string[index] <= \' \'))
{
   index++;
}
new offset = index;
new result[20];
while ((index < length) && (string[index] > \' \') && ((index - offset) < (sizeof(result) - 1)))
{
   result[index - offset] = string[index];
   index++;
}
result[index - offset] = EOS;
return result;
}

Nem elérhető kurta999

  • 2759
  • Éllő fédisznó
    • Profil megtekintése
Givecash parancs.
« Válasz #6 Dátum: 2011. Március 14. - 18:25:01 »
0 Show voters
Pedig ajánlatos a ZCMD meg az sscanf 2, mivel sokkal gyorsabb és jobb.
Bár a strtok se rossz, csak lassú és bonyolultabb.

Penzykee.

  • Vendég
Givecash parancs.
« Válasz #7 Dátum: 2011. Március 14. - 19:00:47 »
0 Show voters
Át konvertáltam a parancsokat de 4 hiba volt benne.. xDD
Köszönöm! :)

Givecash parancs.
« Válasz #8 Dátum: 2011. Március 20. - 15:04:08 »
0 Show voters
Szerintem használd ezt, ez nekem bevált:
 
#include <a_samp>
#include <zcmd>
CMD:givecash(playerid, params[])
{
new giveplayerid, moneys;
if (sscanf(params, \"ui\", giveplayerid, moneys))
{
SendClientMessage(playerid, 0xad1010AA, \"Használat: /givecash [playerid] [pénzösszeg]\");
}
else if (giveplayerid == INVALID_PLAYER_ID)
{
SendClientMessage(playerid, 0xad1010AA, \"Hiba: Nincs ilyen játékos!\");
}
else
{
new playermoney = GetPlayerMoney(playerid);
new playername[MAX_PLAYER_NAME];
new string[128];
if (moneys > 0 && playermoney >= moneys)
{
GivePlayerMoney(playerid, (0 - moneys));
GivePlayerMoney(giveplayerid, moneys);
GetPlayerName(giveplayerid, playername, sizeof (playername));
format(string, sizeof(string), \"Te küldtél %s nevû játékosnak pénzt. Összeg %d $ .\", playername, moneys);
SendClientMessage(playerid, 0x06b28cAA, string);
GetPlayerName(playerid, playername, sizeof (playername));
format(string, sizeof(string), \"%s nevû játékostól pénzt kaptál! Összeg %d $ .\", playername, moneys);
SendClientMessage(giveplayerid, 0x06b28cAA, string);
}
else
{
SendClientMessage(playerid, 0xad1010AA, \"Hiba: Rossz összeg!\");
}
}
return 1;
}
stock sscanf(string[], format[], {Float,_}:...)
{
#if defined isnull
if (isnull(string))
#else
if (string[0] == 0 || (string[0] == 1 && string[1] == 0))
#endif
{
   return format[0];
}
#pragma tabsize 4
new
formatPos = 0,
stringPos = 0,
paramPos = 2,
paramCount = numargs(),
delim = \' \';
while (string[stringPos] && string[stringPos] <= \' \')
{
stringPos++;
}
while (paramPos < paramCount && string[stringPos])
{
switch (format[formatPos++])
{
   case \'\\0\':
   {
      return 0;
   }
   case \'i\', \'d\':
   {
      new
         neg = 1,
         num = 0,
         ch = string[stringPos];
      if (ch == \'-\')
      {
         neg = -1;
         ch = string[++stringPos];
      }
      do
      {
         stringPos++;
         if (\'0\' <= ch <= \'9\')
         {
            num = (num * 10) + (ch - \'0\');
         }
         else
         {
            return -1;
         }
      }
      while ((ch = string[stringPos]) > \' \' && ch != delim);
      setarg(paramPos, 0, num * neg);
   }
   case \'h\', \'x\':
   {
      new
         num = 0,
         ch = string[stringPos];
      do
      {
         stringPos++;
         switch (ch)
         {
            case \'x\', \'X\':
            {
               num = 0;
               continue;
            }
            case \'0\' .. \'9\':
            {
               num = (num << 4) | (ch - \'0\');
            }
            case \'a\' .. \'f\':
            {
               num = (num << 4) | (ch - (\'a\' - 10));
            }
            case \'A\' .. \'F\':
            {
               num = (num << 4) | (ch - (\'A\' - 10));
            }
            default:
            {
               return -1;
            }
         }
      }
      while ((ch = string[stringPos]) > \' \' && ch != delim);
      setarg(paramPos, 0, num);
   }
   case \'c\':
   {
      setarg(paramPos, 0, string[stringPos++]);
   }
   case \'f\':
   {
      new changestr[16], changepos = 0, strpos = stringPos;
      while(changepos < 16 && string[strpos] && string[strpos] != delim)
      {
         changestr[changepos++] = string[strpos++];
                }
      changestr[changepos] = \'\\0\';
      setarg(paramPos,0,_:floatstr(changestr));
   }
   case \'p\':
   {
      delim = format[formatPos++];
      continue;
   }
   case \'\\\'\':
   {
      new
         end = formatPos - 1,
         ch;
      while ((ch = format[++end]) && ch != \'\\\'\') {}
      if (!ch)
      {
         return -1;
      }
      format[end] = \'\\0\';
      if ((ch = strfind(string, format[formatPos], false, stringPos)) == -1)
      {
         if (format[end + 1])
         {
            return -1;
         }
         return 0;
      }
      format[end] = \'\\\'\';
      stringPos = ch + (end - formatPos);
      formatPos = end + 1;
   }
   case \'u\':
   {
      new
         end = stringPos - 1,
         id = 0,
         bool:num = true,
         ch;
      while ((ch = string[++end]) && ch != delim)
      {
         if (num)
         {
            if (\'0\' <= ch <= \'9\')
            {
               id = (id * 10) + (ch - \'0\');
            }
            else
            {
               num = false;
            }
         }
      }
      if (num && IsPlayerConnected(id))
      {
         setarg(paramPos, 0, id);
      }
      else
      {
         #if !defined foreach
            #define foreach(%1,%2) for (new %2 = 0; %2 < MAX_PLAYERS; %2++) if (IsPlayerConnected(%2))
            #define __SSCANF_FOREACH__
         #endif
         string[end] = \'\\0\';
         num = false;
         new
            name[MAX_PLAYER_NAME];
         id = end - stringPos;
         foreach (Player, playerid)
         {
            GetPlayerName(playerid, name, sizeof (name));
            if (!strcmp(name, string[stringPos], true, id))
            {
               setarg(paramPos, 0, playerid);
               num = true;
               break;
            }
         }
         if (!num)
         {
            setarg(paramPos, 0, INVALID_PLAYER_ID);
         }
         string[end] = ch;
         #if defined __SSCANF_FOREACH__
            #undef foreach
            #undef __SSCANF_FOREACH__
         #endif
      }
      stringPos = end;
   }
   case \'s\', \'z\':
   {
      new
         i = 0,
         ch;
      if (format[formatPos])
      {
         while ((ch = string[stringPos++]) && ch != delim)
         {
            setarg(paramPos, i++, ch);
         }
         if (!i)
         {
            return -1;
         }
      }
      else
      {
         while ((ch = string[stringPos++]))
         {
            setarg(paramPos, i++, ch);
         }
      }
      stringPos--;
      setarg(paramPos, i, \'\\0\');
   }
   default:
   {
      continue;
   }
}
while (string[stringPos] && string[stringPos] != delim && string[stringPos] > \' \')
{
   stringPos++;
}
while (string[stringPos] && (string[stringPos] == delim || string[stringPos] <= \' \'))
{
   stringPos++;
}
paramPos++;
}
do
{
if ((delim = format[formatPos++]) > \' \')
{
   if (delim == \'\\\'\')
   {
      while ((delim = format[formatPos++]) && delim != \'\\\'\') {}
   }
   else if (delim != \'z\')
   {
      return delim;
   }
}
}
while (delim > \' \');
return 0;
}

Nem elérhető Flash

  • 5726
  • (っ◕‿◕)っ
    • Profil megtekintése
Givecash parancs.
« Válasz #9 Dátum: 2011. Március 25. - 15:19:45 »
0 Show voters
egyébként a sima LVDM módba van csak le kell magyaroosítani!...

 

SimplePortal 2.3.7 © 2008-2024, SimplePortal