Admin Script Wont Work!?!?!
#1

My code:

pawn Код:
#include <a_samp>
#include <dini>
#include <dudb>
#define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
#if defined FILTERSCRIPT
public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    print(" MADMIN");
    print("--------------------------------------\n");
    return 1;
}

public OnFilterScriptExit()
{
    return 1;
}

#else

main()
{
    print("\n----------------------------------");
    print(" BY: Matt");
    print("----------------------------------\n");
}

#endif

new logged[MAX_PLAYERS];enum pInfo
{
    AdminLevel,
    cash,
    score,
}
new PlayerInfo[MAX_PLAYERS][pInfo];

public OnPlayerConnect(playerid)
{
new name[MAX_PLAYER_NAME];
    new file[128];
    GetPlayerName(playerid, name, sizeof(name));
    format(file,sizeof(file),"/MAdmin/%s.ini",name);
    if(!fexist(file))
    {
    SendClientMessage(playerid, 0x33AA33AA, "You arent registered! type /register to save your stats!");
    logged[playerid] = 0;
    }
    if(fexist(file))
    {
    SendClientMessage(playerid, 0x33AA33AA, "You are registered! type /login [pass]");    }
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
new file[128];
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    format(file,sizeof(file),"/MAdmin/%s.ini",name);
    if(dini_Exists(file))
    {
  dini_IntSet(file, "score", PlayerInfo[playerid][score]);
  dini_IntSet(file, "money", PlayerInfo[playerid][cash]);
  dini_IntSet(file, "AdminLevel",PlayerInfo[playerid][AdminLevel]);
    }
    logged[playerid] = 0;
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    dcmd(register, 8, cmdtext);
    dcmd(login, 5, cmdtext);
    return 0;
}

dcmd_register(playerid, params[])
{
  new file[128], pname[MAX_PLAYER_NAME];
  GetPlayerName(playerid, pname, sizeof(pname));
  format(file, sizeof(file), "\\MAdmin\\%s.ini", pname);
  if(!strlen(params)) return SendClientMessage(playerid, 0xFF0000FF, "[SYSTEM]: /register [password]");
  if(dini_Exists(file)) return SendClientMessage(playerid, 0xFF0000FF, "[SYSTEM]: You are already registered!");
  dini_Create(file);
  dini_IntSet(file, "hashPW", udb_hash(params));
  dini_Set(file, "password", params);
  dini_IntSet(file, "AdminLevel",PlayerInfo[playerid][AdminLevel] = 0);
  dini_IntSet(file, "score", PlayerInfo[playerid][score] = 0);
  dini_IntSet(file, "money", PlayerInfo[playerid][cash] = 500);
  new string[128];
  format(string, 128, "[SYSTEM]: You succesfully registered the nickname %s with password %s", pname, params);
  SendClientMessage(playerid, 0xFFFF00AA, string);
  logged[playerid] = 1;  SendClientMessage(playerid, 0xFFFF00AA, "[SYSTEM]: You have been automatically logged in!");
  return 1;
}

dcmd_login(playerid, params[])
{
  new file[128];
  new string[MAX_STRING], pname[MAX_PLAYER_NAME];
  GetPlayerName(playerid, pname, sizeof(pname));
  format(file, sizeof(file), "\\MAdmin\\%s.ini", pname);
  if(!strlen(params)) return SendClientMessage(playerid, 0xFF0000FF, "[SYSTEM]: /login [password]");
  if(!dini_Exists(file)) return SendClientMessage(playerid, 0xFF0000FF, "[SYSTEM]: You are not registered!");
  if(logged[playerid]) return SendClientMessage(playerid, 0xFF0000FF, "[SYSTEM]: You are already logged in!");
  new tmp;
  tmp = dini_Int(file, "hashPW");
  if(udb_hash(params) != tmp)
  {
    format(string, 256, "You specified the wrong password for %s!", pname);
    SendClientMessage(playerid, 0xFF0000FF, string);
  }
  else
  {
    logged[playerid] = 1;
    PlayerInfo[playerid][AdminLevel] = dini_Int(file, "AdminLevel");
    SetPlayerScore(playerid, PlayerInfo[playerid][score]);
    new lebel = PlayerInfo[playerid][AdminLevel];
    GivePlayerMoney(playerid, dini_Int(file, "money")-GetPlayerMoney(playerid));
    format(string, 256, "[SYSTEM]: Successfully logged in! (level: %d)!", lebel);
        SendClientMessage(playerid,0xFF0000FF, string);
    printf("%s (%i) logged in with password %s", pname, playerid, params);
  }
  return 1;
}
ERRORS:


pawn Код:
\\Tomscomputer\dmserver\filterscripts\madmin2.pwn(41) : warning 217: loose indentation
\\Tomscomputer\dmserver\filterscripts\madmin2.pwn(58) : warning 217: loose indentation
\\Tomscomputer\dmserver\filterscripts\madmin2.pwn(122) : warning 217: loose indentation
\\Tomscomputer\dmserver\filterscripts\madmin2.pwn(123) : warning 217: loose indentation
\\Tomscomputer\dmserver\filterscripts\madmin2.pwn(127) : warning 203: symbol is never used: "ret_memcpy"
\\Tomscomputer\dmserver\filterscripts\madmin2.pwn(127) : warning 203: symbol is never used: "strtok"
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


6 Warnings.
WHAT SHOULD I DO
Reply
#2

http://pastebin.com/Yvcxe3Ry
Reply
#3

And By the way this aren't errors and yes warmnings... Loose identitation are caused by bad scripting... If you read some script cleanup toturials will help much(i am talking by own experience)... You could learn to use the TAB right
Reply
#4

thanks!
Reply
#5

\\Tomscomputer\dmserver\filterscripts\madmin2.pwn( 127) : warning 203: symbol is never used: "ret_memcpy"
\\Tomscomputer\dmserver\filterscripts\madmin2.pwn( 127) : warning 203: symbol is never used: "strtok"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


2 Warnings.

what should i do?
Reply
#6

Add the top

pawn Код:
#pragma unused ret_memcpy
pawn Код:
#pragma unused strtok
Reply
#7

ok. thanks you soooooo much!!!
Reply
#8

what would i do to make a command using dcmd in this script? THANKS!
Reply
#9

This is a ban command I also helped someone before.
Download sscanf2 by ******.

Here.

pawn Код:
public OnPlayerCommandText( playerid, cmdtext[ ] )
{
    dcmd(ban, 3, cmdtext);  // 3 chars. because ban is 3 char long.
    return 0;
}
pawn Код:
dcmd_ban(playerid, params[])
{
    new pID;
    if(PlayerInfo[playerid][AdminLevel] >= 1) {
    if(sscanf(params, "us[128]", pID, params[2])) return SendClientMessage(playerid, Red, "Usage: /ban <playerid/playername> <reason>");
    if(pID == INVALID_PLAYER_ID) return SendClientMessage(playerid, Red, "This player is not connected");
    new string[128];
    new playername[MAX_PLAYER_NAME];
    GetPlayerName(playerid, playername, sizeof(playername));
    format(string,sizeof(string),"%s has been banned from this server. Reason: %s",playername,params[2]);
    SendClientMessageToAll(Red,string);
    Ban(pID);
    } else if(PlayerInfo[playerid][AdminLevel] == 0) return SendClientMessage(playerid, Red, "You are not an admin.");
    return 1;
}
Reply
#10

Quote:
Originally Posted by sciman001
Посмотреть сообщение
\\Tomscomputer\dmserver\filterscripts\madmin2.pwn( 127) : warning 203: symbol is never used: "ret_memcpy"
\\Tomscomputer\dmserver\filterscripts\madmin2.pwn( 127) : warning 203: symbol is never used: "strtok"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


2 Warnings.

what should i do?
Remove that lnes
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)