married couples ? lol..
#1

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 ?
Reply
#2

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

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.
Reply
#4

lol..well do you have the answer ?
Reply
#5

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

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.");
Reply
#7

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.
Reply
#8

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 ..
Reply
#9

And can i get the code for the getplayerdistance ...?
Reply
#10

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


Forum Jump:


Users browsing this thread: 1 Guest(s)