SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 14/11/2018, 10:04 PM   #1
dabv_astur
Little Clucker
 
Join Date: May 2011
Posts: 13
Reputation: 0
Default Problem with a... variable? /goto command

Hi everyone, again me. This error seems to be very basic, but I do not understand what happens and I have the crazy head.

That's is my code:

pawn Code:
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;
}

The problem is when I try teleport with ID 0 to ID 1 I can't and I receive that SendClientMessage:
HTML Code:
[IR] DabvAsturDemo fue a DabvAsturDemo
My main account and also I am trying go to is named DabvAstur

Watch the video so understand me better.
https://*******.com/watch?v=bdTVIX3_D2M
dabv_astur is offline   Reply With Quote
Old 15/11/2018, 01:50 PM   #2
OiLoL
Little Clucker
 
Join Date: Oct 2018
Posts: 2
Reputation: 0
Default Re: Problem with a... variable? /goto command

new vehiculo = GetPlayerVehicleID(playerid);
new seat = GetPlayerVehicleSeat(playerid);

You are doing wrong?

change it to :
idJugador

new vehiculo = GetPlayerVehicleID(idJugador);
new seat = GetPlayerVehicleSeat(idJugador);

You are getting player's vehicle ID and player's seat and placing the same player in that vehicle xD
OiLoL is offline   Reply With Quote
Old 15/11/2018, 02:16 PM   #3
Rolux
Big Clucker
 
Rolux's Avatar
 
Join Date: Jun 2013
Location: u2mu7c7ttj8qt
Posts: 80
Reputation: 20
Default Re: Problem with a... variable? /goto command

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.
Rolux is offline   Reply With Quote
Old 15/11/2018, 08:37 PM   #4
dabv_astur
Little Clucker
 
Join Date: May 2011
Posts: 13
Reputation: 0
Default Re: Problem with a... variable? /goto command

Quote:
Originally Posted by Rolux View Post
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.
Can you please tell me how I do that? With sscanf maybe?
dabv_astur is offline   Reply With Quote
Old 15/11/2018, 08:49 PM   #5
BiGuy
Little Clucker
 
Join Date: Jun 2018
Posts: 17
Reputation: 1
Default Re: Problem with a... variable? /goto command

Quote:
Originally Posted by dabv_astur View Post
Can you please tell me how I do that? With sscanf maybe?
Yes its easy check the examples https://forum.sa-mp.com/showthread.php?t=570927
__________________
Join my discord server 'The BiG Gaming Community':
https://discord.gg/6hzV6VT
BiGuy is offline   Reply With Quote
Old 15/11/2018, 09:48 PM   #6
dabv_astur
Little Clucker
 
Join Date: May 2011
Posts: 13
Reputation: 0
Default Re: Problem with a... variable? /goto command

Quote:
Originally Posted by BiGuy View Post
Yes its easy check the examples https://forum.sa-mp.com/showthread.php?t=570927
if (sscanf(params, "u", idJugador)) return SendClientMessage(playerid, COLOR_RED, "Usa: /ir IDJUGADOR");

I add this line to my command but the result is same

EDIT:
Ok i change "u" parameter with "d" but with that I can't put the username on the command. Maybe because the variable is an integer and not string?
dabv_astur is offline   Reply With Quote
Old 16/11/2018, 08:28 AM   #7
TheToretto
Gangsta
 
TheToretto's Avatar
 
Join Date: Jul 2015
Posts: 586
Reputation: 66
Default Re: Problem with a... variable? /goto command

d and u are will work the same.

Show your new code.
__________________






Toretto#9902

Rest in peace grandpa, 03 November 2018
TheToretto is offline   Reply With Quote
Old 16/11/2018, 05:17 PM   #8
Flofey
Little Clucker
 
Flofey's Avatar
 
Join Date: Oct 2018
Location: South the moon
Posts: 32
Reputation: 11
Default Re: Problem with a... variable? /goto command

I don't know.. but it might work _:_ give it a try tho

PHP Code:
CMD:goto(playeridparams[])
{
    new 
idPlayer;
    new 
Float:xPlayerFloat:yPlayerFloat: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(idPlayerxPlayeryPlayerzPlayer);
              
SetPlayerPos(playeridxPlayeryPlayer+2zPlayer);
              
SetVehiclePos(vehiclexPlayeryPlayer+2zPlayer);
              
PutPlayerInVehicle(playeridvehicleseat);
         }
         else
         {
            
GetPlayerPos(idPlayerxPlayeryPlayerzPlayer);
            
SetPlayerPos(playeridxPlayer+1yPlayer+1zPlayer);

            
format(StringMensizeof StringMen"[GOTO] %s teleported to %s"playernametargetname);
            
SendClientMessage(playerid, -1StringMen);

         }
    }
    else return 
SendClientMessage(playerid, -1"You're not allowed to use this command!");

    return 
1;

PS: sry for using English :P
__________________
Discord: Flofey#8478
Flofey is offline   Reply With Quote
Old 16/11/2018, 06:09 PM   #9
Mencent
High-roller
 
Mencent's Avatar
 
Join Date: Mar 2015
Location: Lower Saxony (Niedersachsen)
Posts: 1,313
Reputation: 92
Default Re: Problem with a... variable? /goto command

Quote:
Originally Posted by TheToretto View Post
d and u are will work the same.
That's wrong. d is only for integers and u is for strings and integers.

_______________________________________-


Try this:
PHP Code:
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(idJugadorxJugadoryJugadorzJugador);
              
SetPlayerPos(playeridxJugadoryJugador+2zJugador);
              
SetVehiclePos(vehiculoxJugadoryJugador+2zJugador);
              
PutPlayerInVehicle(playeridvehiculoseat);
              return 
1;
         }
         else
         {
            
GetPlayerPos(idJugadorxJugadoryJugadorzJugador);
            
SetPlayerPos(playeridxJugador+1yJugador+1zJugador);

            
format(StringMensizeof StringMen"[IR] %s fue a %s"pInfo[playerid][Name], pInfo[idJugador][Name]);
            
SendClientMessage(playeridCOLOR_REDStringMen);
            return 
1;

         }
    }
    else return 
SendClientMessage(playeridCOLOR_RED"No eres staff o no tienes rango suficiente!");

__________________
Best wishes,
Mencent

(Sorry for my bad english, I hope you can understand this!)
Mencent is offline   Reply With Quote
Old 17/11/2018, 07:05 AM   #10
Flofey
Little Clucker
 
Flofey's Avatar
 
Join Date: Oct 2018
Location: South the moon
Posts: 32
Reputation: 11
Default Re: Problem with a... variable? /goto command

Quote:
Originally Posted by Mencent View Post
That's wrong. d is only for integers and u is for strings and integers.

_______________________________________-


Try this:
PHP Code:
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(idJugadorxJugadoryJugadorzJugador);
              
SetPlayerPos(playeridxJugadoryJugador+2zJugador);
              
SetVehiclePos(vehiculoxJugadoryJugador+2zJugador);
              
PutPlayerInVehicle(playeridvehiculoseat);
              return 
1;
         }
         else
         {
            
GetPlayerPos(idJugadorxJugadoryJugadorzJugador);
            
SetPlayerPos(playeridxJugador+1yJugador+1zJugador);

            
format(StringMensizeof StringMen"[IR] %s fue a %s"pInfo[playerid][Name], pInfo[idJugador][Name]);
            
SendClientMessage(playeridCOLOR_REDStringMen);
            return 
1;

         }
    }
    else return 
SendClientMessage(playeridCOLOR_RED"No eres staff o no tienes rango suficiente!");

Excuse me Mencent, isn't what you did is the same as I did but in a different language :/
__________________
Discord: Flofey#8478
Flofey is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Player not connected-Invalid Player id and You can't goto to yourself. "Goto command" KurtAngle Scripting Help 4 28/08/2013 07:14 AM
Anyone can use /goto command? (Urgent problem!!!) Goldino Scripting Help 25 28/01/2013 09:46 PM
Goto command problem nickbouwhuis Scripting Help 2 20/10/2012 03:41 PM
/goto help variable Kar Help Archive 7 12/06/2010 11:02 PM
Problem with /goto command sobolanux Help Archive 0 10/04/2010 02:35 PM


All times are GMT. The time now is 12:31 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.