Admin's SetWorld command by using zcmd and sscanf -
R4VER - 25.08.2012
hey guys as im noob in scripting, ihave another question ^^
i tried to make /setworld playerid worldid command but it didn't worked... is there any tut to teach me how to make it?
Re: Admin's SetWorld command by using zcmd and sscanf -
kbalor - 25.08.2012
Simple and easy..
https://sampforum.blast.hk/showthread.php?tid=361798
pawn Код:
#include <a_samp>
#include <sscanf>
#include <zcmd>
CMD:vw(playerid,params[])
{
new virtualworld;
if(sscanf(params,"i",virtualworld)) return SendClientMessage(playerid,-1,"USAGE: /vw [id]");
else
{
new str[256];
SetPlayerVirtualWorld(playerid,virtualworld);
format(str,sizeof(str),"You are now in virtual world %d",virtualworld);
SendClientMessage(playerid,-1,str);
}
return 1;
}
Re: Admin's SetWorld command by using zcmd and sscanf -
TheArcher - 25.08.2012
@kbalor why did you use 256 when 64 MAX. is needed. If you want only the admin to access to that command just add
pawn Код:
[if(IsPlayerAdmin(playerid)) { //code }
above the string variable.
Re: Admin's SetWorld command by using zcmd and sscanf -
R4VER - 25.08.2012
this one let's the player to change his own virtual world... im trying to create a command which let's admin to change a player's virtual world
Re: Admin's SetWorld command by using zcmd and sscanf -
TheArcher - 25.08.2012
pawn Код:
#include <a_samp>
#include <sscanf>
#include <zcmd>
CMD:vw(playerid,params[])
{
new virtualworld;
if(sscanf(params,"i",virtualworld)) return SendClientMessage(playerid,-1,"USAGE: /vw [id]");
{
if(IsPlayerAdmin(playerid)) {
new str[64];
SetPlayerVirtualWorld(playerid,virtualworld);
format(str,sizeof(str),"You are now in virtual world %d",virtualworld);
SendClientMessage(playerid,-1,str);
} else {
SendClientMessage(playerid,-1,"Only RCON users can access to this command");
}
}
return 1;
}
Here's an example.
Re: Admin's SetWorld command by using zcmd and sscanf -
Universal - 25.08.2012
The above example will output errors.
pawn Код:
#include <a_samp>
#include <sscanf>
#include <zcmd>
COMMAND:setvw(playerid, params[])
{
#pragma unused params
if (IsPlayerAdmin(playerid))
{
new
targetid,
vw;
if (sscanf(params, "dd", targetid, vw))
{
SendClientMessage(playerid, -1, "Syntax: /setvw [playerid] [virtual world]");
return 1;
}
if (vw < 0)
{
SendClientMessage(playerid, -1, "Invalid virtual world specified.");
return 1;
}
if (!IsPlayerConnected(targetid))
{
SendClientMessage(playerid, -1, "Invalid player ID.");
return 1;
}
SetPlayerVirtualWorld(targetid, vw);
SendClientMessage(targetid, -1, "Your virtual world has been changed by an Admin.");
}
return 1;
}
Note that -1 in SendClientMessage is white color, so change that if you want your colors.
Re: Admin's SetWorld command by using zcmd and sscanf -
TheArcher - 25.08.2012
I forgot to add a bracket and the code is not wrong. Also mine was a basic example.
Re: Admin's SetWorld command by using zcmd and sscanf -
R4VER - 25.08.2012
Quote:
Originally Posted by Universal
The above example will output errors.
pawn Код:
#include <a_samp> #include <sscanf> #include <zcmd>
COMMAND:setvw(playerid, params[]) { #pragma unused params if (IsPlayerAdmin(playerid)) { new targetid, vw; if (sscanf(params, "dd", targetid, vw)) { SendClientMessage(playerid, -1, "Syntax: /setvw [playerid] [virtual world]"); return 1; } if (vw < 0) { SendClientMessage(playerid, -1, "Invalid virtual world specified."); return 1; } if (!IsPlayerConnected(targetid)) { SendClientMessage(playerid, -1, "Invalid player ID."); return 1; } SetPlayerVirtualWorld(targetid, vw); SendClientMessage(targetid, -1, "Your virtual world has been changed by an Admin."); } return 1; }
Note that -1 in SendClientMessage is white color, so change that if you want your colors.
|
thx mate
repped