auto spawn
#1

Hey everyone. Sorry that I am asking so many questions. But I really need it.

Well. I want that when you type /login you automaticly spawn with the skin you logged off with. When I log in now, it only switches to the skin in onplayerspawnrequest. I want that you automaticly spawns with it.

This is the script:
Код:
#include <a_samp>
#include <dini>
new stringskin[256];
#include <dutils>//you need this include
#include <dudb>//this too
#define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
#define COLOR_SYSTEM 0xEFEFF7AA
#define MAX_TRIES 3 // Tries number before kick the player
#define COLOR_RED 0xFF0000FF //RED
new PLAYERLIST_authed[MAX_PLAYERS];
new pkills[MAX_PLAYERS];
new pdeaths[MAX_PLAYERS];
new tries[MAX_PLAYERS];
public OnFilterScriptInit()
{
  print("\n================================================================");
  print("         Register system:");
  	print("           Iniciated");
  	print("         Created By: Joaum");
  	print("================================================================");
  	print("\n");
}
stock SystemMsg(playerid,msg[]) {
  if ((IsPlayerConnected(playerid))&&(strlen(msg)>0)) {
    SendClientMessage(playerid,COLOR_SYSTEM,msg);
  }
  return 1;
}

stock PlayerName(playerid) {
 new name[255];
 GetPlayerName(playerid, name, 255);
 return name;
}

 dcmd_register(playerid,params[]) {

  if (PLAYERLIST_authed[playerid]) return SystemMsg(playerid,"You are Already Logged In.");

  if (udb_Exists(PlayerName(playerid))) return SystemMsg(playerid,"Account already exist '/login password'.");

  if (strlen(params)==0) return SystemMsg(playerid,"Correct Usage: '/register password'");

  if (udb_Create(PlayerName(playerid),params)) return SystemMsg(playerid,"Account has been created '/login password' now.");
  return true;

 }

 dcmd_login(playerid,params[]) {

  if (PLAYERLIST_authed[playerid]) return SystemMsg(playerid,"You already are Logged in.");
  if (!udb_Exists(PlayerName(playerid))) return SystemMsg(playerid,"Account doesn't exists '/register password'.");
  if (strlen(params)==0) return SystemMsg(playerid,"Use '/login password'");

  if (udb_CheckLogin(PlayerName(playerid),params)) {
    // Status
    GivePlayerMoney(playerid,dUserINT(PlayerName(playerid)).("money")+GetPlayerMoney(playerid));
    SetPlayerScore(playerid,dUserINT(PlayerName(playerid)).("Score")+GetPlayerScore(playerid));
    SetPlayerSkin(playerid,dUserINT(PlayerName(playerid)).("Skin")+GetPlayerSkin(playerid));
    pkills[playerid] = (playerid,dUserINT(PlayerName(playerid)).("Kills")+pkills[playerid]);
    pdeaths[playerid] = (playerid,dUserINT(PlayerName(playerid)).("Deaths")+pdeaths[playerid]);
    PLAYERLIST_authed[playerid]=true;

    return SystemMsg(playerid,"Succefully Logged in!");
  }
  // Bad Password
  	tries[playerid]++;
  	if(tries[playerid] == MAX_TRIES) {
  SystemMsg(playerid,"You got kicked for too much password mistakes!!");
  print("The Player was kicked for didnt put the password correctly");//lets print this to warn the server
	Kick(playerid);
  }
  	else if (tries[playerid] == MAX_TRIES-1){
  	SendClientMessage(playerid, COLOR_RED, "Next Time You will be kicked!!!");//ouch..
  }
 	return 0;
 }

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

 if(strcmp(cmdtext, "/mystats", true) == 0)
  {
  new stringkills[256];
  new stringmortes[256];
  new stringratio[256];
  new stringscore[256];
  new stringdinheiro[256];
  new Float:ratio=floatdiv(pkills[playerid],pdeaths[playerid]);
  format(stringkills,sizeof(stringkills), "Kills: %d",pkills[playerid]);
  format(stringmortes,sizeof(stringmortes), "Deaths: %d",pdeaths[playerid]);
  format(stringratio,sizeof(stringratio), "Ratio: %.2f",ratio);
  format(stringdinheiro,sizeof(stringdinheiro), "Money: %d",GetPlayerMoney(playerid));
  format(stringscore,sizeof(stringscore), "Score: %d",GetPlayerScore(playerid));
  format(stringskin,sizeof(stringskin), "Skin: %d",GetPlayerSkin(playerid));
  SendClientMessage(playerid, 0xFFFF00AA, "         ");
  SendClientMessage(playerid, 0xFFFF00AA, "Your stats:");
  SendClientMessage(playerid, 0xFFFF00AA, stringkills);
  SendClientMessage(playerid, 0xFFFF00AA, stringmortes);
  SendClientMessage(playerid, 0xFFFF00AA, stringratio);
  SendClientMessage(playerid, 0xFFFF00AA, stringscore);
  SendClientMessage(playerid, 0xFFFF00AA, stringdinheiro);
  SendClientMessage(playerid, 0xFFFF00AA, stringskin);
  SendClientMessage(playerid, 0xFFFF00AA, "        ");
  return 1;
}

 return false;
}

public OnPlayerRequestSpawn(playerid)
{
  if (!PLAYERLIST_authed[playerid]){
  if (udb_Exists(PlayerName(playerid))) {
  SendClientMessage(playerid, COLOR_SYSTEM, "------------------------------------------");
  SendClientMessage(playerid, COLOR_SYSTEM, "|                     |");
  SendClientMessage(playerid, COLOR_SYSTEM, "This Account is Registered /login password ");
  SendClientMessage(playerid, COLOR_SYSTEM, "|                |");
  SendClientMessage(playerid, COLOR_SYSTEM, "------------------------------------------");
  new Float:X;
  	new Float:Y;
  	new Float:Z;
  	GetPlayerPos(playerid, X, Y, Z);
  	PlayerPlaySound(playerid,1147, X, Y, Z);//music
  	return 0;
  }
  	else SendClientMessage(playerid, COLOR_SYSTEM, "You Can Spawn Now!!!");
  }
  return 1;
}

public OnPlayerText(playerid, text[])
{  if (!PLAYERLIST_authed[playerid]){
  if (udb_Exists(PlayerName(playerid))){
  SystemMsg(playerid,"You are not logged in to use The Chat!");
  new Float:X;
  new Float:Y;
  new Float:Z;
  GetPlayerPos(playerid, X, Y, Z);
  PlayerPlaySound(playerid,1147, X, Y, Z);//music
  }
  return 0;
 }
  return 1;
}

public OnPlayerDeath(playerid, killerid, reason)

{

  if (killerid != INVALID_PLAYER_ID) {

     pkills[killerid] ++;
     pdeaths[playerid] ++;
   }


  return 1;

}

 public OnPlayerConnect(playerid) {
 tries[playerid] = 0;
 PLAYERLIST_authed[playerid]=false;
 if (udb_Exists(PlayerName(playerid))) return SendClientMessage(playerid, COLOR_SYSTEM, "Welcome Back! This Account is registred (/Login password)");
 return false;


}

public OnPlayerDisconnect(playerid) {
 if (PLAYERLIST_authed[playerid]) {
   // save
  dUserSetINT(PlayerName(playerid)).("Money",GetPlayerMoney(playerid));
  dUserSetINT(PlayerName(playerid)).("Score",GetPlayerScore(playerid));
  dUserSetINT(PlayerName(playerid)).("Skin",GetPlayerSkin(playerid));
  dUserSetINT(PlayerName(playerid)).("Kills",pkills[playerid]);
  dUserSetINT(PlayerName(playerid)).("Deaths",pdeaths[playerid]);
 }
 PLAYERLIST_authed[playerid]=false;
 return false;
}
Regards, bart.

Thankyou
Reply
#2

anyone knows how to fix?
Reply
#3

Код:
dcmd_login(playerid,params[])
{
  if (PLAYERLIST_authed[playerid]) return SystemMsg(playerid,"You already are Logged in.");
  if (!udb_Exists(PlayerName(playerid))) return SystemMsg(playerid,"Account doesn't exists '/register password'.");
  if (strlen(params)==0) return SystemMsg(playerid,"Use '/login password'");

  if (udb_CheckLogin(PlayerName(playerid),params))
	{
    // Status
    GivePlayerMoney(playerid,dUserINT(PlayerName(playerid)).("money")+GetPlayerMoney(playerid));
    SetPlayerScore(playerid,dUserINT(PlayerName(playerid)).("Score")+GetPlayerScore(playerid));
    SetPlayerSkin(playerid,dUserINT(PlayerName(playerid)).("Skin")+GetPlayerSkin(playerid));
    pkills[playerid] = (playerid,dUserINT(PlayerName(playerid)).("Kills")+pkills[playerid]);
    pdeaths[playerid] = (playerid,dUserINT(PlayerName(playerid)).("Deaths")+pdeaths[playerid]);
    PLAYERLIST_authed[playerid]=true;
    SpawnPlayer(playerid);

    return SystemMsg(playerid,"Succefully Logged in!");
  }
  // Bad Password
  	tries[playerid]++;
  	if(tries[playerid] == MAX_TRIES)
	{
	  SystemMsg(playerid,"You got kicked for too much password mistakes!!");
	  print("The Player was kicked for didnt put the password correctly");//lets print this to warn the server
		Kick(playerid);
  }
  	else if (tries[playerid] == MAX_TRIES-1)
 	{
  		SendClientMessage(playerid, COLOR_RED, "Next Time You will be kicked!!!");//ouch..
	}
	return 0;
}

public OnPlayerSpawn(playerid)
{
	SetPlayerSkin(playerid, dUserINT(PlayerName(playerid)).("Skin"));
	return 1;
}
Reply
#4

DAMN YEAAAA. It is finaly working.
So SO SO Soooo many thanks


BUuuuut...

I can't change my character now xD
Can I fix that?
Reply
#5

well make a command that sets the player skin, i mean, it saves the player skin at the disconnection.
i assume you made this for a roleplay server?
make a cloth shop or something, or just a simple command like /changeskin [skinid]
then his skin changes and saves it at the disconnection.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)