02.08.2012, 01:05
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 ,,
plz guys help me ,,
// 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
// 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;
}
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;
}
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
}
}
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
}
}
new randSpawn = random(4);