PDA

View Full Version : Teleport


lsreskjn
12/06/2013, 11:36 PM
Hey all, i want to make a teleport..something like this

if (strcmp("/pq", cmdtext, true, 10) == 0)
{
SetPlayerPos(playerid, 1519.7275,-1659.0162,13.2662,184.9231);
SendClientMessage(playerid, "You have teleported to Pershing Square");
SendClientMessageToAll(-1, "blablabla!");
return 1;
}
return 0;

The problem is i want everyone to see that the player has teleported but i dont know what to put in the SendMessageToAll to show his name

ReVo_
12/06/2013, 11:43 PM
if (strcmp("/pq", cmdtext, true) == 0)
{
SetPlayerPos(playerid, 1519.7275,-1659.0162,13.2662,184.9231);
SendClientMessage(playerid, "You have teleported to Pershing Square");
new name [MAX_PLAYER_NAME]; // variabile where you store his name
GetPlayerName (playerid, name, 24); // here you get his name, 24 = MAX_PLAYER_NAME you can use MAX_PLAYER_NAME too
new name[128]; // i used 128 here, but you can balance the size based on your message: has teleported to length: 21 + 24 (player name) + 1 (\0) + x (place length)
format (string, sizeof string, "%s has teleported to blabla", name);
SendClientMessageToAll(-1, string);
return 1;
}
return 0;

lsreskjn
12/06/2013, 11:52 PM
oh, thats to complicated i got error, im not sure how to make it work, the stored name :D

ReVo_
12/06/2013, 11:56 PM
if you compile the code you get an error? Can you share the error?

lsreskjn
13/06/2013, 12:07 AM
here it is

Riddick94
13/06/2013, 12:16 AM
SetPlayerPos(playerid, 1519.7275,-1659.0162,13.2662,184.9231);

Four arguments? Should be X, Y, Z only, and Angle can be set in other function.

feartonyb
13/06/2013, 12:16 AM
if (strcmp("/pq", cmdtext, true) == 0)
{
SetPlayerPos(playerid, 1519.7275,-1659.0162,13.2662,184.9231);
SendClientMessage(playerid, "You have teleported to Pershing Square"");
new sendname [MAX_PLAYER_NAME];
GetPlayerName (playerid, sendname, MAX_PLAYER_NAME);
new sendstring[128];
format (sendstring, sizeof sendstring, "%s has teleported to Pershing Square", sendname);
SendClientMessageToAll(-1, sendstring);
return 1;
}

lsreskjn
13/06/2013, 12:19 AM
feartonyb

i got only 2 error now

C:\Users\kjn\Desktop\Untitled.pwn(94) : error 035: argument type mismatch (argument 2)
C:\Users\kjn\Desktop\Untitled.pwn(97) : warning 219: local variable "sendstring" shadows a variable at a preceding level
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase


1 Error.

feartonyb
13/06/2013, 12:22 AM
Sry missed something :D


if (strcmp("/pq", cmdtext, true) == 0)
{
SetPlayerPos(playerid, 1519.7275,-1659.0162,13.2662);
SendClientMessage(playerid, "You have teleported to Pershing Square"");
new sendname[MAX_PLAYER_NAME];
GetPlayerName(playerid, sendname, sizeof(sendname));
new senderstring[128];
format (senderstring, sizeof(senderstring), "%s has teleported to Pershing Square", sendname);
SendClientMessageToAll(-1, senderstring);
return 1;
}

lsreskjn
13/06/2013, 12:25 AM
I still got (94) : error 035: argument type mismatch (argument 2) :mad:

on line:

SendClientMessage(playerid, "You have teleported to Pershing Square");

feartonyb
13/06/2013, 12:32 AM
You didn't put the color, replace that line with

SendClientMessage(playerid, -1, "You have teleported to Pershing Square");

lsreskjn
13/06/2013, 12:34 AM
you're awesome!!! I know this is very simple for you but i am a beginner :D

feartonyb
13/06/2013, 12:37 AM
The thing is that it's 2AM here so I can't really keep my eyes opened so I am sorry I missed the line.
I was a beginner once too, just keep practicing.
And I suggest you that you should make only one command for teleport like /port or /teleport and when you press it show a dialog where are all the locations. It's much simplier to use and looks better

Good luck

lsreskjn
13/06/2013, 12:52 AM
How about you showing me how to do the dialog ? :D

feartonyb
13/06/2013, 12:58 AM
if (strcmp("/teleport", cmdtext, true) == 0)
{
ShowPlayerDialog(playerid, 300, DIALOG_STYLE_LIST, "TELEPORT","Pershing Square", "Teleport", "Off");
return 1;
}



public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == 300)
{
if(response)
{
if(listitem == 0)
{
SetPlayerPos(playerid, 1519.7275,-1659.0162,13.2662);
SendClientMessage(playerid, -1, "You have teleported to Pershing Square"");
new sendname[MAX_PLAYER_NAME];
GetPlayerName(playerid, sendname, sizeof(sendname));
new senderstring[128];
format (senderstring, sizeof(senderstring), "%s has teleported to Pershing Square", sendname);
SendClientMessageToAll(-1, senderstring);
}
}
}
return 1;
}