minigun war
#1

i made minigun war but in the /stopmini command i want that if any player is in mini teleport him and change his virtual world... the problem is how to define that?
pawn Код:
if(inmini[*****] == 1)
{
         SetPlayerPos(playerid, X, Y, Z);
}
plz help... i dont know what to put in *******... dont worry i didnt put X, Y, Z in my real command...
Reply
#2

zcmd:

pawn Код:
COMMAND:minigunwar(playerid, params[])
{
    SetPlayerPos(playerid, X, Y, Z);
    SetPlayerVirtualWorld(playerid, 1); // change to whatever virtual world you want
    return 1;
}
Reply
#3

Quote:
Originally Posted by xir
Посмотреть сообщение
zcmd:

pawn Код:
COMMAND:minigunwar(playerid, params[])
{
    SetPlayerPos(playerid, X, Y, Z);
    SetPlayerVirtualWorld(playerid, 1); // change to whatever virtual world you want
    return 1;
}
i know how to change the virtual world... how can i do that anyone in minigun will teleport if i stop the minigun war?
Reply
#4

That's not hard. When someone enter it, set an integer (eg. 'MiniGunDM[playerid] = 1' / '= true') and when yuo stop it, loop through all the players and when it's '1' or 'true' (if you use a boolean), teleport the player.
I will make an example (I'll edit this post). I will use ZCMD

pawn Код:
#include <a_samp>
#include <zcmd>

new bool:MinigunDM[ MAX_PLAYERS ],
       bool:MinigunDMEnabled

public OnPlayerConnect( playerid )
    MinigunDM[ playerid ] = false;

public OnPlayerDisconnect( playerid )
    MinigunDM[ playerid ] = false;

CMD:togminigundm( playerid, params[] )
{
    if( MinigunDMEnabled ) {
        MinigunDMEnabled = false;
        SendClientMessage( playerid, 0xFF0000AA, "Minigun DM disabled!" );
        for( new i = 0; i < MAX_PLAYERS; i++ ){
            if( MinigunDM[i] ){
                MinigunDM[i] = false;
                SendClientMessage( i, 0xFF0000AA, "The minigun DM has been ended" );
                //Set player pos
            }
        }
    }
    else {
        MinigunDMEnabled = true;
        SendClientMessage( playerid, 0x00FF00AA, "Minigun DM enabled!" );
    }
    return 1;
}

CMD:minigundm( playerid, params[] )
{
    if( MinigunDMEnabled && !MinigunDM[ playerid ] ) {
        SendClientMessage( playerid, 0x00FF00AA, "You have entered the Minigun DM" );
        MinigunDM[ playerid ] = true;
        // set pos
    }
    else
        return SendClientMessage( playerid, 0xFF0000AA, "Or the minigun DM is disabled, or you've already entered it" );
    return 1;
}

CMD:stopminigundm( playerid, params[] )
{
    if( MinigunDM[ playerid ] ) {
        MinigunDM[ playerid ] = true;
        SendClientMessage( playerid, 0x00FF00AA, "You have stopped the minigun DM" );
        // set pos
    }
    else
        return SendClientMessage( playerid, 0xFF0000AA, "You didn't enter the minigun DM yet" );
    return 1;
}
This should be okay. Maybe a typo, but I guess you can fix that
Reply
#5

Quote:
Originally Posted by Kwarde
Посмотреть сообщение
That's not hard. When someone enter it, set an integer (eg. 'MiniGunDM[playerid] = 1' / '= true') and when yuo stop it, loop through all the players and when it's '1' or 'true' (if you use a boolean), teleport the player.
I will make an example (I'll edit this post). I will use ZCMD
i did the first part... but i dont know how to create a loop for all players...
inmini[i]?
Reply
#6

Quote:
Originally Posted by omer5198
Посмотреть сообщение
i did the first part... but i dont know how to create a loop for all players...
inmini[i]?
for(new i = 0; i < MAX_PLAYERS; i++) <- Loop through all the players (500). If you have less players, you should add this to your script:
pawn Код:
#define MAX_PLAYERS 0xF
Change 0xF to the max players of your server (this is for faster loops, less blabla usage, faster amx compiling, less filesize of the .amx). Try to compile a big gamemode, look at the .amx, change the MAX_PLAYERS to something lower, compile it again and see the second filesize.
However, previous post editted.
Reply
#7

Quote:
Originally Posted by Kwarde
Посмотреть сообщение
That's not hard. When someone enter it, set an integer (eg. 'MiniGunDM[playerid] = 1' / '= true') and when yuo stop it, loop through all the players and when it's '1' or 'true' (if you use a boolean), teleport the player.
I will make an example (I'll edit this post). I will use ZCMD
you didn't understood me... i did the /mini and /mini quit commands... now i did the admin commands:
/startmini and /stopmini that open and close the /mini command.
i think that i did it well... check this code and tell me if it's okey as a loop:
pawn Код:
if(strcmp("/stopmini", cmdtext, true, 10) == 0)
{
    minion = 0;
    SendClientMessageToAll(COLOUR_RED, "The Minigun War is now close!");
    new i = 0;
    i = MAX_PLAYERS;
    if(inmini[i])
    {
        SetPlayerPos(i, 2022.4160,1342.7430,10.8203);
    }
    return 1;
}
Edit!!!:
i tried my code... it close the minigun war but it doesn't teleport all the players that were in the war!
Reply
#8

Well it's not okay. You made a new i. First of all: When you make something, it's standard '0.0', '0' or 'false'.
So 'new i = 0;' can just be 'new i'. Secondly, you set the 'i' to 'MAX_PLAYERS' what's standard '500'. So it now only checks for player ID 500 (which will be only avaible when they're that much players online, or alot of NPC's so a player had ID 500).
This'll work:

pawn Код:
if(strcmp("/stopmini", cmdtext, true, 10) == 0)
{
    minion = 0;
    SendClientMessageToAll(COLOUR_RED, "The Minigun War is now close!");

    for(new i = 0; i < MAX_PLAYERS; i++){ //Loop through ID 0-499
        if(inmini[i]){ //Is the player in the minigun madness
            SetPlayerPos(i, 2022.4160,1342.7430,10.8203);
            inmini[i] = false; //Don't forget this. Now he/she ain't there anymore, for the server mostly.
        }
    }
    return 1;
}
Reply
#9

Quote:
Originally Posted by Kwarde
Посмотреть сообщение
Well it's not okay. You made a new i. First of all: When you make something, it's standard '0.0', '0' or 'false'.
So 'new i = 0;' can just be 'new i'. Secondly, you set the 'i' to 'MAX_PLAYERS' what's standard '500'. So it now only checks for player ID 500 (which will be only avaible when they're that much players online, or alot of NPC's so a player had ID 500).
This'll work:

pawn Код:
if(strcmp("/stopmini", cmdtext, true, 10) == 0)
{
    minion = 0;
    SendClientMessageToAll(COLOUR_RED, "The Minigun War is now close!");

    for(new i = 0; i < MAX_PLAYERS; i++){ //Loop through ID 0-499
        if(inmini[i]){ //Is the player in the minigun madness
            SetPlayerPos(i, 2022.4160,1342.7430,10.8203);
            inmini[i] = false; //Don't forget this. Now he/she ain't there anymore, for the server mostly.
        }
    }
    return 1;
}
thx i already did it before...after the edit... but i still didnt understand why the i++ and i didnt put it in my script..
Reply
#10

'i++' : '++' is also '+= 1'. It sets an integer value to '+1'. So you could describe it as this:

'i = i + 1'
'i += 1'
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)