SA-MP Forums Archive
married couples ? lol.. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: married couples ? lol.. (/showthread.php?tid=179625)



married couples ? lol.. - Rocky Balboa - 27.09.2010

hmm i am making a role play server .. and how to something that will make two people a couple ? you know .. only if they are online .. you know .. random ids ..and set the partner id when you spawn .. or something like that .. is that posible ?


Re: married couples ? lol.. - Rocky Balboa - 27.09.2010

OnPlayerSpawn(playerid)
{
new random = playerid +4;
partner[playerid] = random;
}
something like this ?


Re: married couples ? lol.. - Conroy - 27.09.2010

Quote:
Originally Posted by Rocky Balboa
Посмотреть сообщение
OnPlayerSpawn(playerid)
{
new random = playerid +4;
partner[playerid] = random;
}
something like this ?
Randomly marrying people.. if only life was that easy.


Re: married couples ? lol.. - Rocky Balboa - 27.09.2010

lol..well do you have the answer ?


Re: married couples ? lol.. - Retardedwolf - 27.09.2010

Using foreach would be much easier as ****** has provided a function to check for a random connected player.


Re: married couples ? lol.. - Conroy - 27.09.2010

If you want it to be random:

pawn Код:
new MarriedCouple[MAX_PLAYERS];

//OnPlayerConnect
MarriedCouple[playerid] = -1;
for(new i; i <= MAX_PLAYERS; i++)
{
    if(IsPlayerConected(i) && i != playerid && MarriedCouple[i] == -1) {
        MarriedCouple[playerid] = i;
        MarriedCouple[i] = playerid;
        new pname[MAX_PLAYER_NAME], iname[MAX_PLAYER_NAME], pmessage[128], imessage[128];
        GetPlayerName(playerid, pname, sizeof(pname));
        GetPlayerName(i, iname, sizeof(iname));
        format(imessage, sizeof(imessage), "%s is your married partner.", pname);
        format(pmessage, sizeof(pmessage), "%s is your married partner.", iname);
        SendClientMessage(i, COLOR_GREEN, imessage);
        SendClientMessage(playerid, COLOR_GREEN, pmessage);
        break;
    }
}

if(MarriedCouple[playerid] == -1) SendClientMessage(playerid, COLOR_RED, "There is currently no other single people online.");



Re: married couples ? lol.. - [HiC]TheKiller - 27.09.2010

Quote:
Originally Posted by Rocky Balboa
Посмотреть сообщение
OnPlayerSpawn(playerid)
{
new random = playerid +4;
partner[playerid] = random;
}
something like this ?
You cannot define random as it is a PAWN function.


Re: married couples ? lol.. - Rocky Balboa - 28.09.2010

Quote:
Originally Posted by Conroy
Посмотреть сообщение
If you want it to be random:

pawn Код:
new MarriedCouple[MAX_PLAYERS];

//OnPlayerConnect
MarriedCouple[playerid] = -1;
for(new i; i <= MAX_PLAYERS; i++)
{
    if(IsPlayerConected(i) && i != playerid && MarriedCouple[i] == -1) {
        MarriedCouple[playerid] = i;
        MarriedCouple[i] = playerid;
        new pname[MAX_PLAYER_NAME], iname[MAX_PLAYER_NAME], pmessage[128], imessage[128];
        GetPlayerName(playerid, pname, sizeof(pname));
        GetPlayerName(i, iname, sizeof(iname));
        format(imessage, sizeof(imessage), "%s is your married partner.", pname);
        format(pmessage, sizeof(pmessage), "%s is your married partner.", iname);
        SendClientMessage(i, COLOR_GREEN, imessage);
        SendClientMessage(playerid, COLOR_GREEN, pmessage);
        break;
    }
}

if(MarriedCouple[playerid] == -1) SendClientMessage(playerid, COLOR_RED, "There is currently no other single people online.");
That works fine.But how to make a function that would check the distance of partner 1 and distance of partner 2? like this ?
pawn Код:
public Distance(partner1,partner2)
{
    if(MarriedCouple[partner1] != -1 && MarriedCouple[partner1] != -1)
    {
        if(GetPlayerDistance(partner1,partner2) >= 10)
                 {
                      MarriedCouple[partner1] = -1 ;// to break them up .. lol..they have to stay together! for ever!!
                      MarriedCouple[partner2] != -1 ;  
                 }
    }
}
And i use that as a timer ... you know ...under ongamemode ..


Re: married couples ? lol.. - Rocky Balboa - 28.09.2010

And can i get the code for the getplayerdistance ...?


Re: married couples ? lol.. - Steven82 - 28.09.2010

jesus dude were not going to make the whole thing for you.