SA-MP Forums

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

 
 
Thread Tools Display Modes
Old 28/05/2010, 07:26 AM   #1
Faith
Big Clucker
 
Join Date: Sep 2008
Posts: 160
Reputation: 0
Default HELP.. "Friend" system..


I'm thinking of some kind of friend system, where you can /addfriend, /remove friend, and then it shows nametag.

I have an idea to do it something like this:

dini_IntSet ("[playername].txt", [friendsname], 1); (1 = friend, 0 = no friend).
So the file will look like this.
John_O.txt
Dave_L=1 ( FRIEND)
Kurt=0 (NO FRIEND).

Then on player connect, it finds everyone that is friends and will Show nametag within range.
(ofcourse for both parts).

Is there some way to do this?
- Or do you have an even better idea?
Faith is offline  
Old 28/05/2010, 08:30 AM   #2
(SF)Noobanatior
Gangsta
 
Join Date: Dec 2006
Posts: 545
Reputation: 2
Default Re: HELP.. "Friend" system..

why not if your mode already uses dini and your wanting so save friends
(SF)Noobanatior is offline  
Old 28/05/2010, 10:04 AM   #3
Faith
Big Clucker
 
Join Date: Sep 2008
Posts: 160
Reputation: 0
Default Re: HELP.. "Friend" system..

I'm not quite sure how to save the friends into dini files, and then make it show nametag in-game.

But if there is a better way, then i'd like to use that instead
Faith is offline  
Old 28/05/2010, 01:12 PM   #4
Jay_
Gangsta
 
Jay_'s Avatar
 
Join Date: Jul 2009
Posts: 654
Reputation: 197
Default Re: HELP.. "Friend" system..

There is a better way... don't use dini
Jay_ is offline  
Old 28/05/2010, 04:17 PM   #5
Faith
Big Clucker
 
Join Date: Sep 2008
Posts: 160
Reputation: 0
Default Re: HELP.. "Friend" system..

Really?

Do you have any idea how that could be?

Much appreciated, thanks.
Faith is offline  
Old 28/05/2010, 11:55 PM   #6
Faith
Big Clucker
 
Join Date: Sep 2008
Posts: 160
Reputation: 0
Default Re: HELP.. "Friend" system..

I managed to create a file for every player on connect.

John_O.txt

In that file, it now says:
Dave_Sandman=1
Kurt=0
Don_O=1

How can i do, so that it will show nametag for everyone that has the value 1, in that file?.


Thanks in advance.


It looks like this btw:
Code:
public OnPlayerconnect(playerid)
{

// FRIENDS
  new NAME[MAX_PLAYER_NAME];
  GetPlayerName(playerid, NAME, sizeof(NAME));

  format(Friend, sizeof(Friend), "/FRIENDS/%s.txt", NAME);
		if(!dini_Exists(Friend)) { dini_Create(Friend); }


 		dini_IntSet(Friend, NAME, 1); // Just checking the file.

return 1;
}
Faith is offline  
Old 29/05/2010, 08:06 AM   #7
(SF)Noobanatior
Gangsta
 
Join Date: Dec 2006
Posts: 545
Reputation: 2
Default Re: HELP.. "Friend" system..

pawn Code:
public OnPlayerCommandText(playerid, cmdtext[])
{
    new cmd[256],Friend[256];
    new idx;
  cmd = strtok(cmdtext, idx);
 
    if (strcmp("/addfriend", cmd, true, 10) == 0)
    {
   
    if(!strlen(tmp)) {
            SendClientMessage(playerid,0xAFAFAFFF,"Usage: /AddFriend (id)");
            return 1;
        }
        new id = strval(tmp);
        if(!IsPlayerConnected(id)) {
            SendClientMessage(playerid,0xAFAFAFFF,"/AddFriend : Bad player ID");
            return 1;
        }
        if(playerid == id) {
          SendClientMessage(playerid,0xAFAFAFFF,"You Cant be friends with yourself");
            return 1;
        }
        if(!dini_Exists(Friend)) {
            SendClientMessage(playerid,0xAFAFAFFF,"You Dont have a save file");
            return 1;
        }
        new NAME[MAX_PLAYER_NAME],FriendName[MAX_PLAYER_NAME];
        GetPlayerName(playerid, NAME, sizeof(NAME));
        format(Friend, sizeof(Friend), "/FRIENDS/%s.txt", NAME);
      GetPlayerName(id, FriendName, sizeof(FriendName));
        dini_Set(Friend, "Friend1",     FriendName);
        return 1;
        }
    }
    return 0;
}

that should add a name to the file i think not tested though
(SF)Noobanatior is offline  
Old 29/05/2010, 08:29 AM   #8
(SF)Noobanatior
Gangsta
 
Join Date: Dec 2006
Posts: 545
Reputation: 2
Default Re: HELP.. "Friend" system..

and some thing like this to set the friends for a player again not tested but both compile

pawn Code:
public GetPlayersFriends(playerid) {
    new playername[MAX_PLAYER_NAME],friendname[256];
    new fstr[128];
    GetPlayerName(playerid, playername, sizeof(playername));
    format(fstr,sizeof(fstr),"/FRIENDS/%s.txt",playername);
    if (dini_Exists(fstr))  {
        if(dini_Isset(fstr,"Friend1")){
            friendname = dini_Get(fstr, "Friend1");
            for(new i=0;i<MAX_PLAYERS;i++) {
              if(!IsPlayerConnected(i))continue;
              new tmpname[MAX_PLAYER_NAME];
              GetPlayerName(i, tmpname, sizeof(tmpname));
              if (strcmp(friendname, tmpname, true, sizeof(friendname) == 0){
                //found friend on server
                ShowPlayerNameTagForPlayer(playerid,i,true);
              }
            }
             
        }
    }
    return 1;
}
(SF)Noobanatior is offline  
Old 29/05/2010, 09:45 AM   #9
Faith
Big Clucker
 
Join Date: Sep 2008
Posts: 160
Reputation: 0
Default Re: HELP.. "Friend" system..

Damn!

I appreciate your time making this.

I'll look into it right away. Thanks alot!
Faith is offline  
Old 29/05/2010, 08:51 PM   #10
(SF)Noobanatior
Gangsta
 
Join Date: Dec 2006
Posts: 545
Reputation: 2
Default Re: HELP.. "Friend" system..

winning?
(SF)Noobanatior 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
[SOLVED]warning 224: indeterminate array size in "sizeof" expression (symbol "") LarzI Help Archive 2 22/12/2009 04:32 AM
Admin script requires "ReturnUser", "strtok" and "IsNumeric" Rubennnnn Help Archive 1 02/12/2009 06:08 PM
NO servers found when I click "Internet tab" or "official tab" need help plzzz! Jmaster543 Server Support 1 03/05/2009 12:27 AM
"Bots", "AI", "NPCs"... Computer-controlled pedestrians and traffic! ssflsnoob General 2 23/11/2008 06:06 PM


All times are GMT. The time now is 08:37 AM.


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