/tp [id] Problem
#1

pawn Код:
#include <a_samp>
    new tmp[256];
    new OtherID = strval(tmp);

public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/tp", cmdtext, true, 6) == 0)
    {
        new tmp[256];
        new OtherID = strval(tmp);
        }
        if(!strlen(tmp)) return SendClientMessage(playerid, 0xFF0000FF, "Usage: /tp [id]");
        if(!IsPlayerConnected(OtherID) || IsPlayerNPC(OtherID)) return SendClientMessage(playerid,0xFF0000FF,"The player is not online!");
        new Float:X, Float:Y, Float:Z;
        }
        GetPlayerPos(OtherID, X, Y, Z);
        }
        if(IsPlayerInAnyVehicle(playerid))
        {
        SetVehiclePos(GetPlayerVehicleID(playerid), X+5, Y+5, Z);
        }
        else
        {
       SetPlayerPos(playerid, X+5, Y+5, Z);
        }
        SendClientMessage(playerid, 0xFF0000FF, "You've been teleported to the requested player!");
        return 1;
    }
    return 0;
}
It gives me this error "Windows has stopped working"
Reply
#2

All your brackets are wrongly positioned as for one thing.
Reply
#3

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/tp", cmdtext, true, 6) == 0)
    {
        new tmp[256];
        new OtherID = strval(tmp);
        if(!strlen(tmp)) return SendClientMessage(playerid, 0xFF0000FF, "Usage: /tp [id]");
        if(!IsPlayerConnected(OtherID) || IsPlayerNPC(OtherID)) return SendClientMessage(playerid,0xFF0000FF,"The player is not online!");
        new Float:X, Float:Y, Float:Z;
        GetPlayerPos(OtherID, X, Y, Z);
        if(IsPlayerInAnyVehicle(playerid))
        {
            SetVehiclePos(GetPlayerVehicleID(playerid), X+5, Y+5, Z);
        }
        else
        {
            SetPlayerPos(playerid, X+5, Y+5, Z);
        }
        SendClientMessage(playerid, 0xFF0000FF, "You've been teleported to the requested player!");
        return 1;
    }
    return 0;
}
This command won't do what you expect it to do anyway, what it will do is take you or your, and move it +5 degrees forwards. I suggest you use ZCMD and sscanf.
Reply
#4

I give 5 dollars to the person who helps me do it!
Reply
#5

pawn Код:
if(!strcmp(cmd, "/tp"))
    {
        {
        new targetid, string[128];
        if(sscanf(params, "uz", targetid)) return SendClientMessage(playerid, COLOR_WHITE, ""[CMD] / [PlayerID/PartOfName]");
        if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_WHITE, "
[ERROR] Player not connected!");
        else
        {
        new pName[24];
        GetPlayerRame(targetid,pName,128);
        format(string, sizeof(string), "
You succesfully teleported to [%d] %s.",targetid, pName);
        SendClientMessage(playerid,COLOR_RED,string);
        SetPlayerInterior(playerid,GetPlayerInterior(targetid));
        new Float:TPX, Float:TPY, Float:TPZ;
        GetPlayerPos(targetid, TPX, TPY, TPZ);
        SetPlayerPos(playerid, TPX, TPY, TPZ+1);
        }
    }
        return 1;
    }
Replace your command with this one. Works fine
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)