SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 01/12/2019, 08:38 AM   #1
PUP
Little Clucker
 
Join Date: Nov 2019
Posts: 1
Reputation: 0
Post Make /freeze & /unfreeze command!

Hi guys my first post in i show on this post how to make a good /freeze and /unfreeze command !
for this tutorial you need zcmd and & sscanf2
now lets type this stock for get player name
Code:
stock pname(playerid)
{
    new name[MAX_PLAYER_NAME]
    GetPlayerName(playerid, name, sizeof(name))
    return name;
}
And you need define a colors
Code:
#define COLOR_WHITE 0xFFFFFFFF
#define COLOR_RED 0xFF0000FF
#define COLOR_YELLOW 0xFFFF00FF
Now go to make command first i making /freeze
Code:
CMD:freeze(playerid, params[])
now open brackets and type news
Code:
CMD:freeze(playerid, params[])
{
    new string[23 + MAX_PLAYER_NAME],msg[64], id;
}
Okay! now go for check this player admin or no
Code:
CMD:freeze(playerid, params[])
{
    new string[23 + MAX_PLAYER_NAME],msg[64], id;
    if (IsPlayerAdmin(playerid))
    {
        return 1;
    }
    else
    {
        SendClientMessage(playerid, COLOR_RED, "You cannot use the command!");
        return 1;
    }
}
Ok IsPlayerAdmin check is player admin or no if no Send a message that you cannot use this command now go for making a params sscanf for admins!

Code:
CMD:freeze(playerid, params[])
{
    new string[23 + MAX_PLAYER_NAME],msg[64], id;
    if (IsPlayerAdmin(playerid))
    {
        if (sscanf(params, "ii", id)) return SendClientMessage(playerid, COLOR_WHITE, "Usage: /freeze [playerid/playername]");
        return 1;
    }
    else
    {
        SendClientMessage(playerid, COLOR_RED, "You cannot use the command!");
        return 1;
    }
}
Okay! now go for check is player connected or no
Code:
CMD:freeze(playerid, params[])
{
    new string[23 + MAX_PLAYER_NAME],msg[64], id;
    if (IsPlayerAdmin(playerid))
    {
        if (sscanf(params, "ii", id)) return SendClientMessage(playerid, COLOR_WHITE, "Usage: freeze [playerid/playername]");
        if (!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_RED, "Is Player Not Connected!");
        return 1;
    }
    else
    {
        SendClientMessage(playerid, COLOR_RED, "You cannot use the command!");
        return 1;
    }
}
Okay! this check is player connected or no if no send message "Is Player Not Connected" now need make format message and send game text for player that you freezed i using style gametext 5 you can use other styles!
Code:
CMD:freeze(playerid, params[])
{
    new string[23 + MAX_PLAYER_NAME],msg[64], id;
    if (IsPlayerAdmin(playerid))
    {
        if (sscanf(params, "ii", id)) return SendClientMessage(playerid, COLOR_WHITE, "Usage: freeze [playerid/playername]");
        if (!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_RED, "Is Player Not Connected!");
        GameTextForPlayer(playerid, "You Freezed!", 5000, 5);
        format(string, sizeof(string), "( ! ) %s Has Freezed You!!!" pname(playerid));
        format(msg, sizeof(msg), "( ! ) You Freezed %s!" pname(id));
        return 1;
    }
    else
    {
        SendClientMessage(playerid, COLOR_RED, "You cannot use the command!");
        return 1;
    }
}
now go for send formated message to admin and player
Code:
CMD:freeze(playerid, params[])
{
    new string[23 + MAX_PLAYER_NAME],msg[64], id;
    if (IsPlayerAdmin(playerid))
    {
        if (sscanf(params, "ii", id)) return SendClientMessage(playerid, COLOR_WHITE, "Usage: freeze [playerid/playername]");
        if (!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_RED, "Is Player Not Connected!");
        GameTextForPlayer(playerid, "You Freezed!", 5000, 5);
        format(string, sizeof(string), "( ! ) %s Has Freezed You!!!" pname(playerid));
        format(msg, sizeof(msg), "( ! ) You Freezed %s!" pname(id));
        SendClientMessage(id, COLOR_RED, string);
        SendClientMessage(playerid, COLOR_YELLOW, msg);
        return 1;
    }
    else
    {
        SendClientMessage(playerid, COLOR_RED, "You cannot use the command!");
        return 1;
    }
}
Now need toggle player control on character
Code:
CMD:freeze(playerid, params[])
{
    new string[23 + MAX_PLAYER_NAME],msg[64], id;
    if (IsPlayerAdmin(playerid))
    {
        if (sscanf(params, "ii", id)) return SendClientMessage(playerid, COLOR_WHITE, "Usage: /freeze [playerid/playername]");
        if (!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_RED, "Is Player Not Connected!");
        GameTextForPlayer(playerid, "You Freezed!", 5000, 5);
        format(string, sizeof(string), "( ! ) %s Has Freezed You!!!" pname(playerid));
        format(msg, sizeof(msg), "( ! ) You Freezed %s!" pname(id));
        SendClientMessage(id, COLOR_RED, string);
        SendClientMessage(playerid, COLOR_YELLOW, msg);
        TogglePlayerControllable(id, 0);
        return 1;
    }
    else
    {
        SendClientMessage(playerid, COLOR_RED, "You cannot use the command!");
        return 1;
    }
}
Ok /freeze Finished now go for make /unfreeze for /unfreeze you can copy freeze and change game texts message and cmd and TogglePlayerControllable to 1 use it!
Code:
CMD:unfreeze(playerid, params[])
{
    new string[23 + MAX_PLAYER_NAME],msg[64], id;
    if (IsPlayerAdmin(playerid))
    {
        if (sscanf(params, "ii", id)) return SendClientMessage(playerid, COLOR_WHITE, "Usage: /unfreeze [playerid/playername]");
        if (!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_RED, "Is Player Not Connected!");
        GameTextForPlayer(playerid, "You Unfreezed!", 5000, 5);
        format(string, sizeof(string), "( ! ) %s HasUnfreezed You!!!" pname(playerid));
        format(msg, sizeof(msg), "( ! ) You Unfreezed %s!" pname(id));
        SendClientMessage(id, COLOR_RED, string);
        SendClientMessage(playerid, COLOR_YELLOW, msg);
        TogglePlayerControllable(id, 1);
        return 1;
    }
    else
    {
        SendClientMessage(playerid, COLOR_RED, "You cannot use the command!");
        return 1;
    }
}
If i helped you +rep me
PUP is offline   Reply With Quote
Old 04/01/2020, 09:55 AM   #2
Flofey
Little Clucker
 
Flofey's Avatar
 
Join Date: Oct 2018
Location: South the moon
Posts: 32
Reputation: 11
Default Re: Make /freeze & /unfreeze command!

This
Quote:
news
thing is called variables.
Other than that you need to be more specific like for colors defining is it necessary to define colors to run these commands? Nope.
Why using * ii * format character?
i > used as integer
u > player or userid

Better use * u * instead of * i *.

Other than that keep going.
__________________
Discord: Flofey#8478
Flofey 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
[FilterScript] How to make /freeze and /unfreeze command without timer? Justinclaveria123 Filterscripts 3 08/10/2014 11:11 AM
[Tutorial] How to make /freeze & /unfreeze command KhaledElkhourashi Tutorials 5 03/03/2014 05:29 PM
[help with Freeze / unfreeze command] basse Scripting Help 6 30/09/2012 01:07 PM
freeze/unfreeze command phil_lendon Help Archive 5 27/07/2011 06:11 PM
How do i make a /Freeze and /unfreeze using Zcmd spike_killa Help Archive 2 22/06/2010 08:27 PM


All times are GMT. The time now is 12:45 PM.


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