CMD:ir(playerid, params[])
{
new idJugador;
new Float:xJugador, Float:yJugador, Float:zJugador;
new StringMen[64];
if(pInfo[playerid][Admin] >= 1)
{
if(IsPlayerInAnyVehicle(playerid))
{
new vehiculo = GetPlayerVehicleID(playerid);
new seat = GetPlayerVehicleSeat(playerid);
GetPlayerPos(idJugador, xJugador, yJugador, zJugador);
SetPlayerPos(playerid, xJugador, yJugador+2, zJugador);
SetVehiclePos(vehiculo, xJugador, yJugador+2, zJugador);
PutPlayerInVehicle(playerid, vehiculo, seat);
}
else
{
GetPlayerPos(idJugador, xJugador, yJugador, zJugador);
SetPlayerPos(playerid, xJugador+1, yJugador+1, zJugador);
format(StringMen, sizeof StringMen, "[IR] %s fue a %s", pInfo[playerid][Name], pInfo[idJugador][Name]);
SendClientMessage(playerid, COLOR_RED, StringMen);
}
}
else return SendClientMessage(playerid, COLOR_RED, "No eres staff o no tienes rango suficiente!");
return 1;
}
[IR] DabvAsturDemo fue a DabvAsturDemo
Don't listen to that guy.
You are not giving any value to the variable "idJugador",so it's value will be 0. That causes you to teleport to ID 0. |
Yes its easy check the examples https://sampforum.blast.hk/showthread.php?tid=570927
|
CMD:goto(playerid, params[])
{
new idPlayer;
new Float:xPlayer, Float:yPlayer, Float:zPlayer;
new StringMen[64];
new playername[MAX_PLAYER_NAME];
new targetname[MAX_PLAYER_NAME];
GetPlayerName(idPlayer,targetname,sizeof(targetname));
GetPlayerName(playerid,playername,sizeof(playername));
if(Info[playerid][Admin] >= 1)
{
if(sscanf(params,"u",idPlayer)) return SendClientMessage(playerid,-1, "/goto [ID]");
if(!IsPlayerConnected(idPlayer)) return SendClientMessage(playerid, -1, "The ID is wrong or the player isn't online!");
if(IsPlayerInAnyVehicle(playerid))
{
new vehicle = GetPlayerVehicleID(playerid);
new seat = GetPlayerVehicleSeat(playerid);
GetPlayerPos(idPlayer, xPlayer, yPlayer, zPlayer);
SetPlayerPos(playerid, xPlayer, yPlayer+2, zPlayer);
SetVehiclePos(vehicle, xPlayer, yPlayer+2, zPlayer);
PutPlayerInVehicle(playerid, vehicle, seat);
}
else
{
GetPlayerPos(idPlayer, xPlayer, yPlayer, zPlayer);
SetPlayerPos(playerid, xPlayer+1, yPlayer+1, zPlayer);
format(StringMen, sizeof StringMen, "[GOTO] %s teleported to %s", playername, targetname);
SendClientMessage(playerid, -1, StringMen);
}
}
else return SendClientMessage(playerid, -1, "You're not allowed to use this command!");
return 1;
}
CMD:ir(playerid,params[])
{
new idJugador,Float:xJugador,Float:yJugador,Float:zJugador,StringMen[64];
if(pInfo[playerid][Admin] >= 1)
{
if(sscanf(params,"u",idJugador))return SendClientMessage(playerid,-1,"WARNING: /ir [playerid]");
if(!IsPlayerConnected(idJugador))return SendClientMessage(playerid,-1,"playerid doesn't exists");
if(IsPlayerInAnyVehicle(playerid))
{
new vehiculo = GetPlayerVehicleID(playerid);
new seat = GetPlayerVehicleSeat(playerid);
GetPlayerPos(idJugador, xJugador, yJugador, zJugador);
SetPlayerPos(playerid, xJugador, yJugador+2, zJugador);
SetVehiclePos(vehiculo, xJugador, yJugador+2, zJugador);
PutPlayerInVehicle(playerid, vehiculo, seat);
return 1;
}
else
{
GetPlayerPos(idJugador, xJugador, yJugador, zJugador);
SetPlayerPos(playerid, xJugador+1, yJugador+1, zJugador);
format(StringMen, sizeof StringMen, "[IR] %s fue a %s", pInfo[playerid][Name], pInfo[idJugador][Name]);
SendClientMessage(playerid, COLOR_RED, StringMen);
return 1;
}
}
else return SendClientMessage(playerid, COLOR_RED, "No eres staff o no tienes rango suficiente!");
}
That's wrong. d is only for integers and u is for strings and integers.
_______________________________________- Try this: PHP Code:
|
Excuse me Mencent, isn't what you did is the same as I did but in a different language :/
|
That's wrong. d is only for integers and u is for strings and integers. [/PHP]
|
Excuse me Mencent, isn't what you did is the same as I did but in a different language :/
|
Just to clarify, that's not right either and sounds misleading. "u" is explicitly for Usernames/IDs.
|
Not quite, you were trying to use GetPlayerName before ever collecting the ID of the player from the parameter, but then you never actually used the players' names anyway.
|
format(StringMen, sizeof StringMen, "[GOTO] %s teleported to %s", playername,targetname);
CMD:goto(playerid, params[])
{
new idPlayer,Float:xPlayer, Float:yPlayer, Float:zPlayer, StringMen[64], playername[MAX_PLAYER_NAME], targetname[MAX_PLAYER_NAME];
if(IsPlayerAdmin(playerid))
{
if(sscanf(params,"u",idPlayer)) return SendClientMessage(playerid,-1, "/goto [ID]");
if(!IsPlayerConnected(idPlayer)) return SendClientMessage(playerid, -1, "The ID is wrong or the player isn't online!");
if(IsPlayerInAnyVehicle(playerid))
{
new vehicle = GetPlayerVehicleID(playerid);
new seat = GetPlayerVehicleSeat(playerid);
GetPlayerPos(idPlayer, xPlayer, yPlayer, zPlayer);
SetVehiclePos(vehicle, xPlayer, yPlayer+2, zPlayer);
PutPlayerInVehicle(playerid, vehicle, seat);
GetPlayerName(idPlayer,targetname,sizeof(targetname));
GetPlayerName(playerid,playername,sizeof(playername));
format(StringMen, sizeof StringMen, "[GOTO] %s teleported to %s", playername, targetname);
SendClientMessage(playerid, -1, StringMen);
}
else
{
GetPlayerPos(idPlayer, xPlayer, yPlayer, zPlayer);
SetPlayerPos(playerid, xPlayer+1, yPlayer+1, zPlayer);
GetPlayerName(idPlayer,targetname,sizeof(targetname));
GetPlayerName(playerid,playername,sizeof(playername));
format(StringMen, sizeof StringMen, "[GOTO] %s teleported to %s", playername, targetname);
SendClientMessage(playerid, -1, StringMen);
}
}
else return SendClientMessage(playerid, -1, "You're not allowed to use this command!");
return 1;
}