/goto and /bring cmd's problem
#1

i have a problem. my admins cmds goto and bring didnt work. here is the code

/goto

Код:
if(strcmp(cmd, "/goto", true) == 0 && PlayerAdminLevel[playerid] == 1337) // Teleports Admin To A Player
	{
  tmp = strtok(cmdtext, idx);
  if(!strlen(tmp)) {
  SendClientMessage(playerid, COLOR_ERROR, "USAGE: /goto (id)");
  return 1;
  }
  giveplayerid = strval(tmp);

  if(!IsNumeric(tmp)) {
  SendClientMessage(playerid, COLOR_ERROR, "USAGE: /goto (id) ID Must be a number");
  return 1;
  }
  if (IsPlayerConnected(giveplayerid)) {
  SetPlayerInterior(playerid, GetPlayerInterior(giveplayerid));
  new Float:x, Float:y, Float:z;
  new pname[24];
  new aname[24];
  GetPlayerPos(giveplayerid, x,y,z);
  SetPlayerPos(playerid, x+1,y,z);
  GetPlayerName(giveplayerid, pname, 24);
  GetPlayerName(playerid, aname, 24);
  SendClientMessage(playerid, 0xA9A9A9AA, "|_Admin Command Used_|");
  format(string, sizeof(string), "You have teleported to %s(%d)",pname,giveplayerid);
  SendClientMessage(playerid,0xFF7F50AA, string);
  format(string, sizeof(string), "%s(%d) has teleported to %s(%d) [ADMIN COMMAND /GOTO]",aname,playerid,pname,giveplayerid);
  printf("%s", string);
  }
  else {
  format(string, sizeof(string), "ID (%d) Is not an active player", giveplayerid);
  SendClientMessage(playerid, COLOR_ERROR, string);
  }
  return 1;
  }
/bring

Код:
if(strcmp(cmd, "/bring", true) == 0 && PlayerAdminLevel[playerid] == 1337) // Brings A Player To Admin
	{
  tmp = strtok(cmdtext, idx);
  if(!strlen(tmp)) {
  SendClientMessage(playerid, COLOR_ERROR, "USAGE: /bring (id)");
  return 1;
  }
  giveplayerid = strval(tmp);

  if(!IsNumeric(tmp)) {
  SendClientMessage(playerid, COLOR_ERROR, "USAGE: /bring (id) ID Must be a number");
  return 1;
  }
  if (IsPlayerConnected(giveplayerid)) {
  SetPlayerInterior(giveplayerid, GetPlayerInterior(playerid));
  new Float:x, Float:y, Float:z;
  new pname[24];
  new aname[24];
  GetPlayerPos(playerid, x,y,z);
  SetPlayerPos(giveplayerid, x+1,y,z);
  SetPlayerVirtualWorld(giveplayerid,GetPlayerVirtualWorld(playerid));
  GetPlayerName(giveplayerid, pname, 24);
  GetPlayerName(playerid, aname, 24);
  SendClientMessage(playerid, 0xA9A9A9AA, "|_Admin Command Used_|");
  format(string, sizeof(string), "You have brought (teleported) %s(%d) to you",pname,giveplayerid);
  SendClientMessage(playerid,0xFF7F50AA, string);
  format(string, sizeof(string), "%s(%d) has brought (teleported) %s(%d) [ADMIN COMMAND /BRING]",aname,playerid,pname,giveplayerid);
  printf("%s", string);
  }
  else {
  format(string, sizeof(string), "ID (%d) Is not an active player", giveplayerid);
  SendClientMessage(playerid, COLOR_ERROR, string);
  }
  return 1;
  }
pls help!!!!!!!!!!!!!!!!!!!!!!!!!

also how can i make to show some random msg's while the player is in the server for example: we have houses on the server earn money to buy one.
Reply
#2

What's the problem with the cmds?
Reply
#3

Run a timer with how long you want a random message to go.

Код:
new RandomMSG[][] =
{
  "we have houses on the server earn money to buy one",
  "Random Message 2",
  "Random Message 3"
};
Код:
	SetTimer("SendMSG", 60000, true);
	new randMSG = random(sizeof(RandomMSG));
	SendClientMessageToAll(COLOR_FLBLUE, RandomMSG[randMSG]);
Reply
#4

if u want my advice , use dcmd+sscanf which is alot easier and for random message here is it ::

top of script :

Код:
new RD[][] =
{
    "message",
    "message",
    "message",
    "message"
};
under OnGameModeInit :

Код:
SetTimer("RandomMessage", Timeinmilliseconds, true);
bottom of script :

Код:
forward RandomMessage();
public RandomMessage()
{
  	new
    rand = random(sizeof(RD));

  	SendClientMessageToAll(0x6400FFFF, RD[rand]);
  	return 1;
}
Reply
#5

the problem with cmds is that i type /bring and the id but the player didnt come immediatly
Reply
#6

so u mean he come but not immediatly?

then that's lag
Reply
#7

he but not always and if he come or i go i will go very slow over 5 min.
Reply
#8

thanks i solve the problem. thanks for randommsg code.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)