SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 24/11/2011, 07:38 PM   #1
manchestera
Huge Clucker
 
Join Date: Aug 2011
Location: Look Behind You
Posts: 277
Reputation: 5
Default Block cmd

Hi there ive made a DM but i need to add something to it to stop them tping out, and so that the only way they can get out is by typing [/exitdm] how would i do this any help would be great?
__________________

Just Doing This To See My Progress
Scripting Level 30/100
Mapping Level 60/100
manchestera is offline   Reply With Quote
Old 24/11/2011, 07:40 PM   #2
=WoR=G4M3Ov3r
High-roller
 
Join Date: Nov 2010
Location: www.Ambrosia-Servers.com
Posts: 1,762
Reputation: 329
Default Re: Block cmd

You mean you don't want them to get out of the DM Map/Area ?
=WoR=G4M3Ov3r is offline   Reply With Quote
Old 24/11/2011, 07:41 PM   #3
Kayaque
Big Clucker
 
Join Date: Jan 2008
Posts: 143
Reputation: 16
Default Re: Block cmd

Do you have a TP command which you wish to block while in DM, and do you got a variable to check if they are inside a DM arena?
Kayaque is offline   Reply With Quote
Old 24/11/2011, 07:43 PM   #4
AndreT
Gangsta
 
AndreT's Avatar
 
Join Date: Jul 2011
Posts: 966
Reputation: 413
Default Re: Block cmd

What I've done is created a function which checks if the player can teleport or not. This function simply checks if the player is in a deathmatch. If yes, it tells the player to use /leave before teleporting.

pawn Code:
stock CanPlayerTeleport(playerid)
{
    if(minigame{playerid} == DEATHMATCH) // whatever it might look like for you
         return SendClientMessage(playerid, COLOR_RED, "Use /exitdm before teleporting away!"), false;
    return true;
}

// Command
CMD:anyteleport(playerid, params[])
{
    if(!CanPlayerTeleport(playerid))
        return true;

    // Teleport the player
    return true;
}
AndreT is offline   Reply With Quote
Old 24/11/2011, 07:45 PM   #5
manchestera
Huge Clucker
 
Join Date: Aug 2011
Location: Look Behind You
Posts: 277
Reputation: 5
Default Re: Block cmd

Right now all i have is.

And yes i dont want them to get out of the map using a tp cmd or any over type of cmd.

[code]
cmd:mdm(playerid)
}
SetPlayerPos(playerid, 2386.0559,1031.2997,10.5261);
return 1;
{
__________________

Just Doing This To See My Progress
Scripting Level 30/100
Mapping Level 60/100
manchestera is offline   Reply With Quote
Old 24/11/2011, 07:50 PM   #6
Kayaque
Big Clucker
 
Join Date: Jan 2008
Posts: 143
Reputation: 16
Default Re: Block cmd

Alright, try this..
Top of your script: new DeathMatch[MAX_PLAYERS];
then, when then enter the DM arena, like /startdm or whatever, you add DeathMatch[playerid] = 1;
Then, if they try to teleport, you check for DeathMatch[playerid] == 0. If it's NOT 0, you return error message.

Something like this;

pawn Code:
new DeathMatch[MAX_PLAYERS];
CMD:mdm(playerid, input[])
{
    DeathMatch[playerid] = 1;
    SetPlayerPos(playerid, 2386.0559,1031.2997,10.5261);
    GameTextForPlayer(playerid, "~w~You entered the ~r~DM zone!", 3000, 4);
    return 1;
}

CMD:teleport(playerid, input[])
{
    if(DeathMatch[playerid] != 0) return SendClientMessage(playerid, color_here, "You can not TP from DM. Use /exitdm to leave.");
   
    // continue the normal code here..
    return 1;
}

CMD:exitdm(playerid, input[])
{
    if(DeathMatch[playerid] != 1) return SendClientMessage(playerid, color_here, "You are not in any DM arenas.");
   
    SetPlayerPos(playerid, /*wherever you wish him to spawn after using /exitdm*/);
    GameTextForPlayer(playerid, "~w~You have left the ~r~DM zone!", 3000, 4);
    return 1;
}
Kayaque is offline   Reply With Quote
Old 24/11/2011, 07:56 PM   #7
manchestera
Huge Clucker
 
Join Date: Aug 2011
Location: Look Behind You
Posts: 277
Reputation: 5
Default Re: Block cmd

so i need to add this to every cmd?

Code:
 if(DeathMatch[playerid] != 0) return SendClientMessage(playerid, color_here, "You can not TP from DM. Use /exitdm to leave.");
__________________

Just Doing This To See My Progress
Scripting Level 30/100
Mapping Level 60/100
manchestera is offline   Reply With Quote
Old 24/11/2011, 07:57 PM   #8
Kayaque
Big Clucker
 
Join Date: Jan 2008
Posts: 143
Reputation: 16
Default Re: Block cmd

Only to the commands that allows them to teleport away from the DM area obviously.
Kayaque is offline   Reply With Quote
Old 24/11/2011, 08:15 PM   #9
manchestera
Huge Clucker
 
Join Date: Aug 2011
Location: Look Behind You
Posts: 277
Reputation: 5
Default Re: Block cmd

Works a treat thanks man.
__________________

Just Doing This To See My Progress
Scripting Level 30/100
Mapping Level 60/100
manchestera is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to block ip xinix000 Help Archive 1 21/08/2010 07:45 AM
block id 02manchestera Help Archive 16 03/04/2010 07:44 AM
Ken Block. SaW Everything and Nothing 32 31/01/2010 10:12 PM
How can I block SA-MP from being used? Ace_Menace Client Support 4 16/10/2009 07:35 PM
Block CJ101 Help Archive 6 27/03/2009 11:18 AM


All times are GMT. The time now is 12:02 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.