open.mp forum
[Pawn] How i can add this to my command? - Printable Version

+ open.mp forum (https://forum.open.mp)
-- Forum: SA-MP (https://forum.open.mp/forumdisplay.php?fid=3)
--- Forum: Pawn Scripting (https://forum.open.mp/forumdisplay.php?fid=10)
--- Thread: [Pawn] How i can add this to my command? (/showthread.php?tid=1678)



How i can add this to my command? - Nicolas_Belic - 2021-02-18

Hi, how can I make it so that only I can teleport to people who are in the same virtual world and cannot if the virtual world is different?





Code:
CMD:goto(playerid, params[]) {

? ?

? ? ? ? if (!sscanf(params, "d", params[0])) {

? ? ? ? ? ? if (IsPlayerConnected(params[0])) {

? ? ? ? ? ? ? ? if(GetPlayerVirtualWorld(params[0]) == GetPlayerVirtualWorld (playerid)) else SendClientMessage(playerid, -1, "Nope");

? ? ? ? ? ? ? ? new Float: p_x,Float: p_y,Float: p_z;

? ? ? ? ? ? ? ? GetPlayerPos(params[0], p_x, p_y, p_z);

? ? ? ? ? ? ? ? new interior = GetPlayerInterior(params[0]);

? ? ? ? ? ? ? ? new vw = GetPlayerVirtualWorld(params[0]);

? ? ? ? ? ? ? ? SetPlayerPos(playerid, p_x, p_y, p_z);

? ? ? ? ? ? ? ? SetPlayerInterior(playerid, interior);

? ? ? ? ? ? ? ? SetPlayerVirtualWorld(playerid, vw);

? ? ? ? ? ? ? ? return SendClientMessage(playerid, -1, "Teleported.");

? ? ? ? ? ? } else SendClientMessage(playerid, -1, "Player not found.");

? ? ? ? } else SendClientMessage(playerid, -1, "/goto [playerid]");

? ? ? ? return 1;

}







Correct me please


RE: How i can add this to my command? - Radical - 2021-02-18

PHP Code:
CMD:goto(playeridparams[]) {



? ? ? ? if (!
sscanf(params"d"params[0])) {

? ? ? ? ? ? if (
IsPlayerConnected(params[0])) {

? ? ? ? ? ? ? ? if(
GetPlayerVirtualWorld(params[0]) != GetPlayerVirtualWorld (playerid)) return SendClientMessage(playerid, -1"Nope");

? ? ? ? ? ? ? ? new 
Floatp_x,Floatp_y,Floatp_z;

? ? ? ? ? ? ? ? 
GetPlayerPos(params[0], p_xp_yp_z);

? ? ? ? ? ? ? ? new 
interior GetPlayerInterior(params[0]);

? ? ? ? ? ? ? ? new 
vw GetPlayerVirtualWorld(params[0]);

? ? ? ? ? ? ? ? 
SetPlayerPos(playeridp_xp_yp_z);

? ? ? ? ? ? ? ? 
SetPlayerInterior(playeridinterior);

? ? ? ? ? ? ? ? 
SetPlayerVirtualWorld(playeridvw);

? ? ? ? ? ? ? ? return 
SendClientMessage(playerid, -1"Teleported.");

? ? ? ? ? ? } else 
SendClientMessage(playerid, -1"Player not found.");

? ? ? ? } else 
SendClientMessage(playerid, -1"/goto [playerid]");

? ? ? ? return 
1