SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Help Archive

 
 
Thread Tools Display Modes
Old 14/03/2011, 03:17 PM   #1
Rivera
Big Clucker
 
Join Date: Feb 2011
Posts: 143
Reputation: 7
Default Suggestions

What should I script? I can't think ANYTHING. I want to create a RP script, but from where should I begin from. I created a /register and /login system, but I got a problem with this. Where is the data saved? I think it should be a 'Users' folder, but I can't find it :P I have scripted only a few cmds, because I am out of ideas. Also I am leaving anims for the last touch. Pls suggest me something and solve my /login /register problem
__________________
My works

[Tutorial]Full usage of dcmd(updated)
[Tutorial]Login/Register System with dialogs


// Prefered Servers------------------------------

US-RP.INFO / Best Roleplay Server / 213.5.176.156:7777

^^__^^
Rivera is offline  
Old 14/03/2011, 03:19 PM   #2
XFlawless
Guest
 
Posts: n/a
Default Re: Suggestions

Post code of /login and /register
 
Old 14/03/2011, 03:22 PM   #3
Rivera
Big Clucker
 
Join Date: Feb 2011
Posts: 143
Reputation: 7
Default Re: Suggestions

'kk here:

/login and /register (all the data):

pawn Code:
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),"/Users/%s.ini",name);
    if(!fexist(file))
    {
    SendClientMessage(playerid, COLOR_GREEN, "[SYSTEM]:You arent registered! type /register to save your stats!");
    logged[playerid] = 0;
    }
    if(fexist(file))
    {
    SendClientMessage(playerid, COLOR_GREEN, "[SYSTEM]: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),"/Users/%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;
}

dcmd_register(playerid, params[])
{
  new file[128], pname[MAX_PLAYER_NAME];
  GetPlayerName(playerid, pname, sizeof(pname));
  format(file, sizeof(file), "\\Users\\%s.ini", pname);
  if(!strlen(params)) return SendClientMessage(playerid, COLOR_RED, "[SYSTEM]: /register [password]");
  if(dini_Exists(file)) return SendClientMessage(playerid, COLOR_RED, "[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, COLOR_YELLOW, string);
  logged[playerid] = 1;
  SendClientMessage(playerid, COLOR_YELLOW, "[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), "\\Users\\%s.ini", pname);
  if(!strlen(params)) return SendClientMessage(playerid, COLOR_RED, "[SYSTEM]: /login [password]");
  if(!dini_Exists(file)) return SendClientMessage(playerid, COLOR_RED, "[SYSTEM]: You are not registered!");
  if(logged[playerid]) return SendClientMessage(playerid, COLOR_RED, "[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, COLOR_RED, 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,COLOR_RED, string);
    printf("%s (%i) logged in with password %s", pname, playerid, params);
  }
  return 1;
}
__________________
My works

[Tutorial]Full usage of dcmd(updated)
[Tutorial]Login/Register System with dialogs


// Prefered Servers------------------------------

US-RP.INFO / Best Roleplay Server / 213.5.176.156:7777

^^__^^
Rivera is offline  
Old 14/03/2011, 03:25 PM   #4
Rivera
Big Clucker
 
Join Date: Feb 2011
Posts: 143
Reputation: 7
Default Re: Suggestions

PROBLEM solved!!! YEAH!
__________________
My works

[Tutorial]Full usage of dcmd(updated)
[Tutorial]Login/Register System with dialogs


// Prefered Servers------------------------------

US-RP.INFO / Best Roleplay Server / 213.5.176.156:7777

^^__^^
Rivera is offline  
Old 14/03/2011, 03:25 PM   #5
XFlawless
Guest
 
Posts: n/a
Default Re: Suggestions

pawn Code:
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),"/Users/%s.ini",name);
    if(!fexist(file))
    {
      SendClientMessage(playerid, COLOR_GREEN, "[SYSTEM]:You arent registered! type /register to save your stats!");
    logged[playerid] = 0;
    }
    else
    {
       SendClientMessage(playerid, COLOR_GREEN, "[SYSTEM]: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),"/Users/%s.ini",name);
    if(dini_Exists(file))// Instead of this i suggest you to use PVars
    {
  dini_IntSet(file, "score", GetPlayerScore(playerid));
  dini_IntSet(file, "money", GetPlayerMoney(playerid));
  dini_IntSet(file, "AdminLevel",PlayerInfo[playerid][AdminLevel]);
    }
    logged[playerid] = 0;
}

dcmd_register(playerid, params[])
{
  new file[128], pname[MAX_PLAYER_NAME];
  GetPlayerName(playerid, pname, sizeof(pname));
  format(file, sizeof(file), "\\Users\\%s.ini", pname);
  if(!strlen(params)) return SendClientMessage(playerid, COLOR_RED, "[SYSTEM]: /register [password]");
  if(dini_Exists(file)) return SendClientMessage(playerid, COLOR_RED, "[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, COLOR_YELLOW, string);
  logged[playerid] = 1;
  SendClientMessage(playerid, COLOR_YELLOW, "[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), "\\Users\\%s.ini", pname);
  if(!strlen(params)) return SendClientMessage(playerid, COLOR_RED, "[SYSTEM]: /login [password]");
  if(!dini_Exists(file)) return SendClientMessage(playerid, COLOR_RED, "[SYSTEM]: You are not registered!");
  if(logged[playerid]) return SendClientMessage(playerid, COLOR_RED, "[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, COLOR_RED, string);
  }
  else
  {
    logged[playerid] = 1;
    PlayerInfo[playerid][AdminLevel] = dini_Int(file, "AdminLevel");
    SetPlayerScore(playerid, dini_Int(file, "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,COLOR_RED, string);
    printf("%s (%i) logged in with password %s", pname, playerid, params);
  }
  return 1;
}
 
Old 14/03/2011, 03:27 PM   #6
Rivera
Big Clucker
 
Join Date: Feb 2011
Posts: 143
Reputation: 7
Default Re: Suggestions

Now, give me some suggestions. How can I script a /fly ADMIN ONLY cmd?!
__________________
My works

[Tutorial]Full usage of dcmd(updated)
[Tutorial]Login/Register System with dialogs


// Prefered Servers------------------------------

US-RP.INFO / Best Roleplay Server / 213.5.176.156:7777

^^__^^
Rivera is offline  
Old 14/03/2011, 03:31 PM   #7
XFlawless
Guest
 
Posts: n/a
Default Re: Suggestions

Quote:
Originally Posted by Rivera View Post
Now, give me some suggestions. How can I script a /fly ADMIN ONLY cmd?!
pawn Code:
CMD:fly(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, 0XFFFFFFFF," You are not authorized to use this command");
else
{
 // Your fly codes here
}
return 1;
}
 
Old 14/03/2011, 03:32 PM   #8
Rivera
Big Clucker
 
Join Date: Feb 2011
Posts: 143
Reputation: 7
Default Re: Suggestions

Quote:
// Your fly codes here
What should I type in my fly code I mean? I want to fly in the air and go around in every place I want BY FLYING... can u help me?
__________________
My works

[Tutorial]Full usage of dcmd(updated)
[Tutorial]Login/Register System with dialogs


// Prefered Servers------------------------------

US-RP.INFO / Best Roleplay Server / 213.5.176.156:7777

^^__^^
Rivera is offline  
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need some suggestions Namaco Everything and Nothing 8 16/12/2010 06:21 PM
Need some suggestions ... Danny Help Archive 1 11/12/2010 12:55 PM
[Need]Suggestions Tigerbeast11 Help Archive 8 05/11/2009 05:51 PM
Little Suggestions for SA:MP 0.3 pLaTaNo General 2044 15/10/2009 04:51 PM


All times are GMT. The time now is 01:20 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.