SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 17/11/2018, 07:11 AM   #11
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 Flofey View Post
Excuse me Mencent, isn't what you did is the same as I did but in a different language :/
Sorry, my mistake. Next time I will look better.
__________________
Best wishes,
Mencent

(Sorry for my bad english, I hope you can understand this!)
Mencent is offline   Reply With Quote
Old 17/11/2018, 12:26 PM   #12
CantBeJohn
Big Clucker
 
CantBeJohn's Avatar
 
Join Date: Oct 2016
Posts: 112
Reputation: 15
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. [/PHP]
Just to clarify, that's not right either and sounds misleading. "u" is explicitly for Usernames/IDs.
CantBeJohn is offline   Reply With Quote
Old 17/11/2018, 02:38 PM   #13
Joe Staff
High-roller
 
Join Date: Aug 2007
Posts: 2,596
Reputation: 379
Default Re: Problem with a... variable? /goto command

Quote:
Originally Posted by Flofey View Post
Excuse me Mencent, isn't what you did is the same as I did but in a different language :/
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.
Joe Staff is offline   Reply With Quote
Old 17/11/2018, 03:44 PM   #14
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 CantBeJohn View Post
Just to clarify, that's not right either and sounds misleading. "u" is explicitly for Usernames/IDs.
Well I mean the right but write the wrong. Sorry and thanks for your correction!
__________________
Best wishes,
Mencent

(Sorry for my bad english, I hope you can understand this!)
Mencent is offline   Reply With Quote
Old 17/11/2018, 08:28 PM   #15
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 Joe Staff View Post
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.
Code:
format(StringMen, sizeof StringMen, "[GOTO] %s teleported to %s", playername,targetname);
and what do you call these?
__________________
Discord: Flofey#8478
Flofey is offline   Reply With Quote
Old 17/11/2018, 09:04 PM   #16
Joe Staff
High-roller
 
Join Date: Aug 2007
Posts: 2,596
Reputation: 379
Default Re: Problem with a... variable? /goto command

Quote:
Originally Posted by Flofey View Post
Code:
format(StringMen, sizeof StringMen, "[GOTO] %s teleported to %s", playername,targetname);
and what do you call these?
Guess I miss that, either way you still placed the GetPlayerName in the wrong place, as well as not reiterating the message when the player is in a vehicle.

In relation to both provided solutions, when teleporting a player that is in a vehicle, you don't actually have to teleport the player, then the vehicle, then place the player in the vehicle. You can actually just teleport the vehicle, the player that's in it will just teleport with the vehicle.
Joe Staff is offline   Reply With Quote
Old 17/11/2018, 09:50 PM   #17
TheToretto
Gangsta
 
TheToretto's Avatar
 
Join Date: Jul 2015
Posts: 586
Reputation: 66
Default Re: Problem with a... variable? /goto command

Use GetPlayerName after the sscanf
__________________






Toretto#9902

Rest in peace grandpa, 03 November 2018
TheToretto is offline   Reply With Quote
Old 18/11/2018, 05:06 AM   #18
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

Thanks for correcting me.


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

    new 
idPlayer,Float:xPlayerFloat:yPlayerFloat:zPlayerStringMen[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(idPlayerxPlayeryPlayerzPlayer);
              
SetVehiclePos(vehiclexPlayeryPlayer+2zPlayer);
              
PutPlayerInVehicle(playeridvehicleseat);
              
GetPlayerName(idPlayer,targetname,sizeof(targetname));
              
GetPlayerName(playerid,playername,sizeof(playername));
              
format(StringMensizeof StringMen"[GOTO] %s teleported to %s"playernametargetname);
              
SendClientMessage(playerid, -1StringMen);
         }
         else
         {
            
GetPlayerPos(idPlayerxPlayeryPlayerzPlayer);
            
SetPlayerPos(playeridxPlayer+1yPlayer+1zPlayer);

            
GetPlayerName(idPlayer,targetname,sizeof(targetname));
            
GetPlayerName(playerid,playername,sizeof(playername));
            
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;

__________________
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 09:47 AM.


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