dm script ??
#1

plz guys i have /dm tp i want to be like dm if player death he come from dm until he /leavedm , how can i made it and how i disable cmds in /dm

plz guys help me ,,
Reply
#2

With only one per-player global variable you can do all the work. Let me show how that would happen:

pawn Код:
// top of script
new Dming[MAX_PLAYERS];
// We gonna set the value of this variable to 1 when a player joins a dm, and to 0 when a player leaves a dm.
// As I said above we will set it to 1 while in dm, so whenever you initialize a player for dm, put this:
Dming[playerid] = 1; // which tells the script that "playerid" is in a dm
// now you can use OnPlayerSpawn to respawn a player ('dm-er') to the dm arena after death
public OnPlayerSpawn(playerid)
{
    if(Dming[playerid] == 1) // if was in a dm (This won't work if you set Dming to 0 under OnPlayerDeath)
    {
        // Respawn
    }
    return 1;
}

public OnPlayerConnect(playerid)
{
    Dming[playerid] = 0; // when a player connects set it to 0 (To avoid ids conflicts)
    return 1;
}
// And in your leavedm command remember to set Dming to 0
Dming[playerid] = 0; // out of dm
Reply
#3

can u explain it all plz , what i write in OnPlayerCommandText and how can i add cmd /leavedm ?

plz explain it all
Reply
#4

Hmm I thought you already have the commands. Well, I explained everything here (Read the comments):
pawn Код:
// top of script
new Dming[MAX_PLAYERS];
// We gonna set the value of this variable to 1 when a player joins a dm, and to 0 when a player leaves a dm.
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(!strcmp(cmdtext, "/dm", true))
    {
        // As I said above we will set it to 1 while in dm
        Dming[playerid] = 1;
        // After that you can add your other codes, teleports, weapons and stuff
        return 1;
    }
    if(!strcmp(cmdtext, "/leavedm", true))
    {
        Dming[playerid] = 0; // tells the script that the player is out of any dm
        SpawnPlayer(playerid); // spawn
        return 1;
    }
    return 0;
}

// now for the OnPlayerSpawn part. This callback is called when a player spawns
public OnPlayerSpawn(playerid)
{
    if(Dming[playerid] == 1) // if was in a dm (This won't work if you set Dming to 0 under OnPlayerDeath)
    {
        // Respawn
        // Simply add the codes that you added in /dm
    }
    return 1;
}
public OnPlayerConnect(playerid)
{
    Dming[playerid] = 0; // when a player connects set it to 0 (To avoid ids conflicts)
    return 1;
}
Hope you got it.
Reply
#5

hey i add this but my pawn just crashing when i prees compile/run
Reply
#6

Compiles fine right here. Do you mind showing what you've done?
Reply
#7

i think the big lines in my gamemode make like that i change it to FS ,

how can i do player cant do anycmds and how can i do many spawn in /dm because its spawn from one place only

plz help
Reply
#8

To disable commands just use the Dming variable. Example:
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(!strcmp(cmdtext, "/SomeCommand", true))
    {
        if(Dming[playerid] == 1) // if in dm
            return SendClientMessage(playerid, -1, "This command is disabled in dms!"); // return error
           
        // Not in dm, do your command.
        return 1;
    }
    return 0;
}
For many spawns you should use Random which generates a pseudo-random number. Example:

pawn Код:
new randSpawn = random(4); // 4 is the highest possible random number. So this is suposed to choose between 4 spawns ('numbers') randomally
// The above code will generate a random number of four numbers (Starting from 0 not 1)
switch(randSpawn)
{
    case 0: // if randSpawn equals to 0 (First Spawn?)
    {
        // Your first spawn place code
    }
    case 1: // if randSpawn equals to 0 (Second Spawn?)
    {
        // Your second spawn place code
    }
    case 2: // if randSpawn equals to 0 (Third Spawn?)
    {
        // Your third spawn place code
    }
    case 3: // if randSpawn equals to 0 (Forth Spawn?)
    {
        // Your forth spawn place code
    }
}
Reply
#9

where can i put
PHP код:
switch(randSpawn)
{
    case 
0// if randSpawn equals to 0 (First Spawn?)
    
{
        
// Your first spawn place code
    
}
    case 
1// if randSpawn equals to 0 (Second Spawn?)
    
{
        
// Your second spawn place code
    
}
    case 
2// if randSpawn equals to 0 (Third Spawn?)
    
{
        
// Your third spawn place code
    
}
    case 
3// if randSpawn equals to 0 (Forth Spawn?)
    
{
        
// Your forth spawn place code
    
}

where , in /dm cmd and i remove SetPlayerPos ?

and i got error with return !!
Reply
#10

Just replace it with your SetPlayerPos and don't forget to put
pawn Код:
new randSpawn = random(4);
before the switch statement.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)