27.02.2012, 22:12
how can i create an cmd like this i type /dmv [playerid/id] and the person goes to Dmv.get it?please helpFast!Rep
1221.1116,-1814.8745,16.5938 coords like /cityhall playerid then i sends him to this coords.
|
public OnPlayerCommandText(playerid,cmdtext[])
{
if(!strcmp(cmdtext,"/cityhall",true))
{
SetPlayerPos(playerid,1221.1116,-1814.8745,16.5938);
return 1;
}
return 0;
}
pawn Код:
|
pawn Код:
|
CMD:cityhall(playerid,params[])
{
new targetid;
if(!IsPlayerAdmin(playerid)) //This is an Admin-Only command.
{
return SendClientMessage(playerid,0xFFFFFFFF," You are not authorized to use that command.");
}
if(sscanf(params,"i",targetid))
{
return SendClientMessage(playerid,0xFFFFFFFF,"USAGE: /cityhall [playerid]");
}
if(i == INVALID_PLAYER_ID)
{
return SendClientMessage(playerid,0xFFFFFFFF,"Player not found.");
}
else
{
new Admin[24],string[50];
GetPlayerName(playerid,Admin,sizeof(Admin));
format(string,sizeof(string),"Administrator %s has teleported you to City Hall.");
SendClientMessage(targetid,0xFFFFFFFF,string);
SetPlayerPos(targetid,1221.1116,-1814.8745,16.5938);
return 1;
}
return 1;
}
This is wrong. He wants to send a targetid to the cityhall. Not himself.
This is using ZCMD and sscanf. You should use it. It is fast, easy, and much more practical than using a string comparer as a command processor. pawn Код:
|
if(strcmp(cmd, "/cityhall", true) == 0)