/setpos help +REP
#1

Script
Код:
CMD:setpos(playerid,params[])
{
	if(!IsPlayerAdmin(playerid))return SendClientMessage(playerid,0xFF0000FF,"<!>You are not authorized to use this command!");
	new Float:x,Float:y,Float:z;
	if(sscanf(params,"uii",x,y,z))return SendClientMessage(playerid,COL_GREEN,"USAGE: /setpos [x] [y] [z]");
	SetPlayerPos(playerid,x,y,z);
	return 1;
}
the cmd is supposed to work like the following: i write the x/y/z position and i get teleported there , i tested it with /setpos 0 0 0 and it worked , but when i do anything other than 0 0 0 i still teleport to 0 0 0 any help ?

Thanks
Reply
#2

Try: :P
PHP код:
command(setposplayeridparams[]) {
    new 
Float:xFloat:yFloat:zPortMsg[128];
    if(!
IsPlayerAdmin(playerid))return SendClientMessage(playerid,0xFF0000FF,"<!>You are not authorized to use this command!");
    if (
sscanf(params"fff"xyz))return SendClientMessage(playerid0xFF0000AA"Use: /setpos [x] [y] [z]");
    
SetPlayerPos(playeridxyz);
    
format(PortMsg128"Vocк foi teleportado para a posiзгo: %4.2f, %4.2f, %4.2f"xyz);
    
SendClientMessage(playerid0x00FF00FFPortMsg);
    return 
1;

Reply
#3

:b
PHP код:
CMD:setpos(playerid,params[])
{
    if(!
IsPlayerAdmin(playerid))return SendClientMessage(playerid,0xFF0000FF,"<!>You are not authorized to use this command!");
    new 
Float:xFloat:yFloat:z;
    new 
tmp[128], tmp2[128], tmp3[128];
    new 
Index;    tmp strtok(params,Index); tmp2 strtok(params,Index); tmp3 strtok(params,Index);
    if(
sscanf(params,"uii",x,y,z))return SendClientMessage(playerid,COL_GREEN,"USAGE: /setpos [x] [y] [z]");
    
strval(tmp);        strval(tmp2);        strval(tmp3);
    
SetPlayerPos(playerid,x,y,z);
    return 
1;
}

strtok(const string[], &index)
{
    new 
length strlen(string);
    while ((
index length) && (string[index] <= ' '))
    {
        
index++;
    }

    new 
offset index;
    new 
result[20];
    while ((
index length) && (string[index] > ' ') && ((index offset) < (sizeof(result) - 1)))
    {
        
result[index offset] = string[index];
        
index++;
    }
    
result[index offset] = EOS;
    return 
result;

Reply
#4

Код:
CMD:setpos(playerid,params[])
{
	if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,0xFF0000FF,"<!>You are not authorized to use this command!");
	new Float:x,Float:y,Float:z, Index, tmp[256], tmp2[256], tmp3[256], str[256];
	tmp = strtok(params, Index);
        tmp2 = strtok(params, Index);
        tmp3 = strtok(params, Index);
        if(isnull(tmp) || isnull(tmp2) || isnull(tmp3)) return SendClientMessage(playerid, 0xFF0000FF, "Usage: /setpos [x] [y] [z]");
        x = strval(tmp);
        y = strval(tmp2);
        z = strval(tmp3);
	if(GetPlayerState(playerid) == 2) SetVehiclePos(GetPlayerVehicleID(playerid),x,y,z);
	else SetPlayerPos(playerid,x,y,z);
	format(str,sizeof(str),"You have teleported to %f, %f, %f", x,y,z);    
        SendClientMessage(playerid, 0xFF0000FF, str);
	return 1;
} 

strtok(const string[], &index)
{
    new length = strlen(string);
    while ((index < length) && (string[index] <= ' '))
    {
        index++;
    }

    new offset = index;
    new result[20];
    while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
    {
        result[index - offset] = string[index];
        index++;
    }
    result[index - offset] = EOS;
    return result;
}
Reply
#5

Thanks , +Repped
Reply
#6

dude wtf: could have been made lot easier :
PHP код:
CMD:setpos(playeridparams[])
{
new 
Pos[3];
if(
sscanf(params"fff"Pos[0], Pos[1], Pos[2])) return SendClientMessage(playeridCOLOR_WHITE"** /setpos x y z"));
SetPlayerPos(playeridPos[0], Pos[1], Pos[2]);
return 
1;

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)