CMD:gethere(playerid,params[])
{
if(pInfo[playerid][pAdminLevel] >= 1)
{
new targetid,string[256], str1[256];
if(sscanf(params, "u", targetid)) SendClientMessage(playerid,-1,""COL_RED"AdmCmds: /gethere [PlayerID]");
if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid,-1,""COL_RED"ERROR: Not online!");
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
SetPlayerPos_Allow(targetid, x+1, y+1, z+1);
GetPlayerPos(playerid,Float:x,Float:y,Float:z);
SetPlayerVirtualWorld(targetid,GetPlayerVirtualWorld(playerid));
format(string, sizeof(string), ""COL_RED"AdmCmds: %s %s has brought you to himself.", GetAdminName(playerid), PlayerName(playerid));
format(str1, sizeof(str1), ""COL_RED"%s %s used /gethere upon %s.", GetAdminName(playerid),PlayerName(playerid),PlayerName(targetid));
SendClientMessage(targetid,-1,string);
SendMessageToAllAdmins(str1,-1);
if(IsPlayerInAnyVehicle(targetid))
{
SetVehiclePos(GetPlayerVehicleID(targetid),x,y,z);
}
}
else {
SendClientMessage(playerid,-1,""COL_RED"EROARE: You are not admin!");
}
return 1;
}
SetPlayerOrVehiclePos(playerid, Float:x, Float:y, Float:z) //A function to teleport a player checking if he's on foot or in a vehicle
{
if(IsPlayerInAnyVehicle(playerid)) //If player is in a vehicle
{
SetVehiclePos(GetPlayerVehicleID(playerid), x, y, z); //Teleport vehicle(will also teleport the player alongside)
}
else //If he isn't in a vehicle
{
SetPlayerPos(playerid, x, y, z); //Teleport him alone
}
return true;
}
CMD:gethere(playerid, params[])
{
if(pInfo[playerid][pAdminLevel] < 1) return SendClientMessage(playerid,-1,""COL_RED"EROARE: You are not admin!");
new targetid;
if(sscanf(params, "u", targetid)) SendClientMessage(playerid,-1,""COL_RED"AdmCmds: /gethere [PlayerID]");
if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid,-1,""COL_RED"ERROR: Not online!");
new Float:x,Float:y,Float:z, string[128];
SetPlayerInterior(targetid, GetPlayerInterior(playerid));
SetPlayerVirtualWorld(targetid, GetPlayerVirtualWorld(playerid));
GetPlayerPos(playerid,Float:x,Float:y,Float:z);
SetPlayerPos_Allow(targetid,Float:x,Float:y,Float:z);
if(IsPlayerInAnyVehicle(targetid))
{
SetVehiclePos(GetPlayerVehicleID(targetid), x, y, z);
LinkVehicleToInterior(GetPlayerVehicleID(targetid),GetPlayerInterior(playerid));
PutPlayerInVehicle(targetid, GetPlayerVehicleID(targetid), 0);
}
format(string, sizeof(string), ""COL_RED"AdmCmds: %s %s has brought you to himself.", GetAdminName(playerid), PlayerName(playerid));
SendClientMessage(targetid, -1, string);
format(string, sizeof(string), ""COL_RED"%s %s used /gethere upon %s.", GetAdminName(playerid), PlayerName(playerid), PlayerName(targetid));
SendMessageToAllAdmins(string, -1);
return 1;
}
I told you earlier dont create multiple variable, one is enough to send multiple messages...
anyway here you go, with code optimization: pawn Код:
|
CMD:gethere(playerid, params[])
{
if(pInfo[playerid][pAdminLevel] < 1) return SendClientMessage(playerid,-1,""COL_RED"EROARE: You are not admin!");
new targetid;
if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /get [playerid]");
if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid,COLOR_RED,"Player is not online");
new Float:x, Float:y, Float:z, string[128], SecondPlayerVeh, FirstPlayerWorld, FirstPlayerInt, bool:VehicleCheck;
if(IsPlayerInAnyVehicle(targetid)) VehicleCheck = true;
FirstPlayerInt = GetPlayerInterior(playerid);
FirstPlayerWorld = GetPlayerVirtualWorld(playerid);
SecondPlayerVeh = GetPlayerVehicleID(targetid);
GetPlayerPos(playerid, x, y, z);
SetPlayerInterior(targetid, FirstPlayerInt);
SetPlayerVirtualWorld(targetid, FirstPlayerWorld);
if(VehicleCheck)
{
SetVehicleVirtualWorld(SecondPlayerVeh, FirstPlayerWorld);
SetVehiclePos(SecondPlayerVeh, x, y, z);
LinkVehicleToInterior(SecondPlayerVeh, FirstPlayerInt);
PutPlayerInVehicle(targetid, SecondPlayerVeh, 0);
}
else SetPlayerPos_Allow(targetid, x, y, z);
format(string, sizeof(string), ""COL_RED"AdmCmds: %s %s has brought you to himself.", GetAdminName(playerid), PlayerName(playerid));
SendClientMessage(targetid, -1, string);
format(string, sizeof(string), ""COL_RED"%s %s used /gethere upon %s.", GetAdminName(playerid), PlayerName(playerid), PlayerName(targetid));
SendMessageToAllAdmins(string, -1);
return true;
}