16.01.2014, 20:01
Hello,
I have known that some of the people is complaining about the commands bugs.
So i decided to make a small tutorial with /freeze /unfreeze command so you can work with it easily.
Let's make /freeze & /unfreeze command.
First of all you need to define & Include your includes
Like:
Ok let's explain
This line is very important, Cause you can't make any command without putting
Or you can replace it with the SAMP normal command function.
Then you need to put "{" to open the section for the script so you can continue script
PS: If you didn't open after making the command line with this "{" and end with this "}" Your codes will get a lot of warnings/errors. So take care.
This line to get the player info, Cause if he is an Admin he can use it.
Or you can remove this line if you want it for Normal players
Also ">= 1)" this is the Admin level you can set it as you wish so the level you will put only the Admins +X Can you use the command. 1-2-3-4-5-6-7-8-9-10 etc.
You need to put another "{" cause you opened new section.
This line to check if the player connected or not online.
This is the message when the Admin types the command /freeze, If the player isn't connected then this is the client message that the Admin will get so he will be notified that the player isn't connected.
/freeze command depends on this line.
This line makes the player Frozen/Unfrozen
If you typed (id,0) then the player will be frozen
If you typed (id,1) then the player will be unfrozen
This is the message the player will get when you make /freeze command on him
As you see the "}" we closed it after we finished the command.
But its not finished yet.
You need to put "return 1;" in any command at THE LAST DON'T PUT IT ON THE FIRST CAUSE IT WILL BUG YOUR COMMAND.
Also you must close the second "}" after you finish "return 1;"
But be careful don't put { } in anything, Just put it when we open new section then you need to close the
second section
But its still in the first section
Then close the first
}
Then you're done with /freeze command.
Now /unfreeze
All same but you change
With
As i said in the first its for freeze/unfreeze
So, We are done
Hope you learned something from me
I have known that some of the people is complaining about the commands bugs.
So i decided to make a small tutorial with /freeze /unfreeze command so you can work with it easily.
Let's make /freeze & /unfreeze command.
First of all you need to define & Include your includes
Like:
PHP Code:
#include <a_samp>
#include <zcmd>
#include <sscanf2>
PHP Code:
CMD:freeze(playerid,params[])
{
if(PlayerInfo[playerid][Admin] >= 1)
{
new id;
if(sscanf(params,"u",id)) return SendClientMessage(playerid,0xFF0000AA,"USAGE: /freeze [playerid]");
if(!IsPlayerConnected(id)) return SendClientMessage(playerid,0xFF0000AA,"ERROR: Invalid playerid");
TogglePlayerControllable(id,0);
SendClientMessage(playerid,0xFF0000AA,"( ! ) You are frozen by an Admin ! ");
}
return 1;
}
PHP Code:
CMD:Unfreeze (playerid, params[])
PHP Code:
"CMD:Unfreeze(playerid,params[])"
PHP Code:
if (strcmp, cmd, "/freeze", true ) == 0 )
PS: If you didn't open after making the command line with this "{" and end with this "}" Your codes will get a lot of warnings/errors. So take care.
PHP Code:
if(PlayerInfo[playerid][Admin] >= 1)
Or you can remove this line if you want it for Normal players
Also ">= 1)" this is the Admin level you can set it as you wish so the level you will put only the Admins +X Can you use the command. 1-2-3-4-5-6-7-8-9-10 etc.
You need to put another "{" cause you opened new section.
PHP Code:
if(!IsPlayerConnected(id))
PHP Code:
return SendClientMessage(playerid,0xFF0000AA,"ERROR: Invalid playerid");
PHP Code:
TogglePlayerControllable(id,0);
This line makes the player Frozen/Unfrozen
If you typed (id,0) then the player will be frozen
If you typed (id,1) then the player will be unfrozen
PHP Code:
SendClientMessage(playerid,0xFF0000AA,"( ! ) You are frozen by an Admin ! ");
As you see the "}" we closed it after we finished the command.
But its not finished yet.
You need to put "return 1;" in any command at THE LAST DON'T PUT IT ON THE FIRST CAUSE IT WILL BUG YOUR COMMAND.
Also you must close the second "}" after you finish "return 1;"
But be careful don't put { } in anything, Just put it when we open new section then you need to close the
second section
But its still in the first section
Then close the first
}
Then you're done with /freeze command.
Now /unfreeze
PHP Code:
CMD:unfreeze(playerid,params[])
{
if(PlayerInfo[playerid][Admin] >= 1)
{
new id;
if(sscanf(params,"u",id)) return SendClientMessage(playerid,0xFF0000AA,"USAGE: /unfreeze [playerid]");
if(!IsPlayerConnected(id)) return SendClientMessage(playerid,0xFF0000AA,"ERROR: Invalid playerid");
TogglePlayerControllable(id,1);
SendClientMessage(playerid,0xFF0000AA,"( ! ) You are unfrozen by an Admin ");
}
return 1;
}
PHP Code:
TogglePlayerControllable(id,0);
PHP Code:
TogglePlayerControllable(id,1);
So, We are done
Hope you learned something from me