Whats wrong with this code? help :S
#1

So Ive just made a Co-ordinate Generator, That Saves The co ords to a file Ill Release it
i now need to make the Teleports
Ive got one teleport code, I got it from the samp forums This is the code

#define FILTERSCRIPT
#include <a_samp>
public OnPlayerCommandText(playerid, cmdtext[]) {
if (!strcmp(cmdtext,"/teleport",true)) { // /center is what the player enter into the text field
if (IsPlayerInAnyVehicle(playerid)) { //Checks if player is inside a vehicle
SetVehiclePos(GetPlayerVehicleID(playerid),0.0,0.0 ,200.0); // Teleports the vehicle
SendClientMessage(playerid, 0xEE66EEFF, "Teleportation Successful");
} else {
SetPlayerPos(playerid,653.954895,-1223.468139,17.173387); // teleports the player
SendClientMessage(playerid, 0xEE66EEFF, "Teleportation Successful");
}
return 1;
}
return 0;
}


That Code works fine and teleports me Fine
but its Time to add another Teleport
Like /drift1 /drift2
i dont wanna make lots of Pwn Files containing one teleport each
how would i Make it twice?
I Copied and pasted it below and it gives me loads of errors
ive put it Above the returns still errors
can Someone Rewrite That, With no errors, The same teleport twice?
Hope that makes Sence, So i can see the patten and make like 10 teleports For cool locations

Thanks Guys
-Lipsmoker

Reply
#2

Something like this?:

pawn Код:
#include <a_samp>

#define COLOR 0xEE66EEFF

public OnPlayerCommandText(playerid, cmdtext[])
{
    if(!strcmp(cmdtext,"/teleport",true))
    {
        if(IsPlayerInAnyVehicle(playerid))
        {
      SetVehiclePos(GetPlayerVehicleID(playerid),0.0,0.0,200.0);
      SendClientMessage(playerid, COLOR, "Teleportation Successful");
    }
        else
        {
      SetPlayerPos(playerid,653.954895,-1223.468139,17.173387); // teleports the player
      SendClientMessage(playerid, COLOR, "Teleportation Successful");
        }
    }
    if(!strcmp(cmdtext, "/drift1",true))
    {
      if(IsPlayerInAnyVehicle(playerid))
      {
        SetVehiclePos(GetPlayerVehicleID(playerid),0,0,200); //EDIT IT!
        SendClientMessage(playerid, COLOR, "Teleportation succesful");
        }
        else
        {
          SetPlayerPos(playerid,0,0,200); //EDIT IT!
          SendClientMessage(playerid, COLOR, "Teleportation succesful");
        }
    }
    return 0;
}
Reply
#3

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp(cmdtext,"/teleport",true)==0) { // /center is what the player enter into the text field
    if(IsPlayerInVehicle(playerid,GetPlayerVehicleID(playerid))) { //Checks if player is inside a vehicle
    SetVehiclePos(GetPlayerVehicleID(playerid),0.0,0.0,200.0); // Teleports the vehicle
        SendClientMessage(playerid, 0xEE66EEFF, "Teleportation Successful");
        } else {
        SetPlayerPos(playerid,653.954895,-1223.468139,17.173387); // teleports the player
        SendClientMessage(playerid, 0xEE66EEFF, "Teleportation Successful");
        }
        return 1;
        }
       
if (strcmp(cmdtext,"/teleport",true)==0) { // /center is what the player enter into the text field
    if(IsPlayerInVehicle(playerid,GetPlayerVehicleID(playerid))) { //Checks if player is inside a vehicle
    SetVehiclePos(GetPlayerVehicleID(playerid),0.0,0.0,200.0); // Teleports the vehicle
        SendClientMessage(playerid, 0xEE66EEFF, "Teleportation Successful");
    } else {
        SetPlayerPos(playerid,653.954895,-1223.468139,17.173387); // teleports the player
        SendClientMessage(playerid, 0xEE66EEFF, "Teleportation Successful");
    }
    return 1;
    }
return 0;
}
Reply
#4

Yeah but mine one is clearer. xD
Reply
#5

Quote:
Originally Posted by Kwarde
Yeah but mine one is clearer. xD
Worked great thanks a Bunch
You got msn? Or xfire, For future Referance

Cheers mate
Reply
#6

If you have a lot of teleports that code can get ugly really quick.

pawn Код:
stock TeleportPlayer(playerid,Float:x,Float:y,Float:z,text[]="You have been teleported",color=0xFFFFFFFF)
{
  If(IsPlayerInAnyVehicle(playerid))SetVehiclePosition(GetPlayerVehicleID(playerid),x,y,z));
  else SetPlayerPos(playerid,x,y,z);
  return SendClientMessage(playerid,color,text);
}
Which can be used like so

pawn Код:
public OnPlayerCommandText(playerid,cmdtext[])
{
  if(!strcmp(cmdtext[1],"drift1",true))return TeleportPlayer(playerid,0.0,0.0,0.0,"You've been teleported the drift area 1",0xFFAAFFFF);
  if(!strcmp(cmdtext[1],"drift2",true))return TeleportPlayer(playerid,0.0,0.0,0.0,"You've been teleported the drift area 2",0xAAFFAAFF);
  return 0;
}
Reply
#7

cheers mate im stuck with a map can u add mcferson123 on xfire please
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)