Mixing dcmd and cmdtext?
#1

I'm trying to make a small register/login/stats-script, but I need some help.
Here's my OnPlayerCommandText:
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(!strcmp(cmdtext, "/stats", true))
    {
        new str[128];
        format(str, 128, "Kills: %d | Deaths: %d", dUserINT(PlayerName(playerid)).("kills"), dUserINT(PlayerName(playerid)).("deaths"));
        SendClientMessage(playerid, 0xFF0000AA, str);
        return true;
    }
    dcmd(register,8,cmdtext);
    dcmd(login,5,cmdtext);
} <-- LINE 120
But I get this:
Quote:

C:\Documents and Settings\Andreas\Mine dokumenter\GTA\samp02Xserver.win32\samp02Xserver.w in32\gamemodes\test.pwn(120) : warning 209: function "OnPlayerCommandText" should return a value

And I also need some help with this:
Quote:

C:\Documents and Settings\Andreas\Mine dokumenter\GTA\samp02Xserver.win32\samp02Xserver.w in32\gamemodes\test.pwn(73) : warning 202: number of arguments does not match definition

pawn Код:
public OnPlayerDisconnect(playerid) {
 if (PLAYERLIST_authed[playerid]) {
  dUserSetINT(PlayerName(playerid)).("money",GetPlayerMoney(playerid));
  dUserSetINT(PlayerName(playerid)).("skin",SetPlayerSkin(playerid)); <-- LINE 73
 }
 PLAYERLIST_authed[playerid]=false;
 return false;
}
Can anyone help me out?
Reply
#2

You may not have put a return in one of your DCMDs, if you post them here, as well as labeling the lines mentioned in the error messages we'd be able to provide help.
Reply
#3

My DCMDs:
pawn Код:
dcmd_register(playerid,params[]) {
  if (PLAYERLIST_authed[playerid]) return SystemMsg(playerid,"Already authed.");
  if (udb_Exists(PlayerName(playerid))) return SystemMsg(playerid,"Account already exists, please use '/login password'.");
  if (strlen(params)==0) return SystemMsg(playerid,"Correct usage: '/register password'");
  if (udb_Create(PlayerName(playerid),params)) return SystemMsg(playerid,"Account successfully created. Login with '/login password' now.");
  return true;

}

dcmd_login(playerid,params[]) {
  if (PLAYERLIST_authed[playerid]) return SystemMsg(playerid,"Already authed.");
  if (!udb_Exists(PlayerName(playerid))) return SystemMsg(playerid,"Account doesn't exist, please use '/register password'.");
  if (strlen(params)==0) return SystemMsg(playerid,"Correct usage: '/login password'");
  if (udb_CheckLogin(PlayerName(playerid),params)) {
    GivePlayerMoney(playerid,dUserINT(PlayerName(playerid)).("money")-GetPlayerMoney(playerid));
    SetPlayerSkin(playerid,dUserINT(PlayerName(playerid)).("skin"));
    PLAYERLIST_authed[playerid]=true;
    return SystemMsg(playerid,"Successfully authed!");
  }
  return SystemMsg(playerid,"Login failed!");
}
Reply
#4

Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
	if(!strcmp(cmdtext, "/stats", true))
	{
		new str[128];
		format(str, 128, "Kills: %d | Deaths: %d", dUserINT(PlayerName(playerid)).("kills"), dUserINT(PlayerName(playerid)).("deaths"));
		SendClientMessage(playerid, 0xFF0000AA, str);
		return true;
	}
	dcmd(register,8,cmdtext);
	dcmd(login,5,cmdtext);
	return 0;
}
Код:
SetPlayerSkin(playerid)
to
Код:
GetPlayerSkin(playerid)
Reply
#5

Quote:
Originally Posted by Jefff
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
	if(!strcmp(cmdtext, "/stats", true))
	{
		new str[128];
		format(str, 128, "Kills: %d | Deaths: %d", dUserINT(PlayerName(playerid)).("kills"), dUserINT(PlayerName(playerid)).("deaths"));
		SendClientMessage(playerid, 0xFF0000AA, str);
		return true;
	}
	dcmd(register,8,cmdtext);
	dcmd(login,5,cmdtext);
	return 0;
}
Код:
SetPlayerSkin(playerid)
to
Код:
GetPlayerSkin(playerid)
Are you sure you want me to place that code anywhere in my /stats?
Maybe in my dcmd_login? I changed to GetPlayerSkin where I wrote LINE 224:

pawn Код:
dcmd_login(playerid,params[]) {
  if (PLAYERLIST_authed[playerid]) return SystemMsg(playerid,"Already authed.");
  if (!udb_Exists(PlayerName(playerid))) return SystemMsg(playerid,"Account doesn't exist, please use '/register password'.");
  if (strlen(params)==0) return SystemMsg(playerid,"Correct usage: '/login password'");
  if (udb_CheckLogin(PlayerName(playerid),params)) {
    GivePlayerMoney(playerid,dUserINT(PlayerName(playerid)).("money")-GetPlayerMoney(playerid));
    GetPlayerSkin(playerid,dUserINT(PlayerName(playerid)).("skin")); <-- LINE 224
    PLAYERLIST_authed[playerid]=true;
    return SystemMsg(playerid,"Successfully authed!");
  }
  return SystemMsg(playerid,"Login failed!");
}
Now I get
Quote:

C:\Documents and Settings\Andreas\Mine dokumenter\GTA\samp02Xserver.win32\samp02Xserver.w in32\gamemodes\test.pwn(224) : warning 202: number of arguments does not match definition

instead
Reply
#6

Код:
SetPlayerSkin(playerid,dUserINT(PlayerName(playerid)).("skin"));
xD

here must be Get not Set

Код:
public OnPlayerDisconnect(playerid) {
 if (PLAYERLIST_authed[playerid]) {
  dUserSetINT(PlayerName(playerid)).("money",GetPlayerMoney(playerid));
  dUserSetINT(PlayerName(playerid)).("skin",GetPlayerSkin(playerid)); <-- LINE 73
 }
 PLAYERLIST_authed[playerid]=false;
 return false;
}
Reply
#7

Quote:
Originally Posted by Jefff
Код:
SetPlayerSkin(playerid,dUserINT(PlayerName(playerid)).("skin"));
xD
Well, that's what I had originally.. It still won't work. When I exit the game the userfile will just update the "Skin=" with "1" again, which is CJ's skin.
Reply
#8

Thanks, Jefff! Now it's working!
Another thing I did wrong was that I logged in before I spawned. Now as I tried to spawn first and then log in, I was given the skin ID which I set in the userfile.
Thanks!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)