Help||Command Text
#1

Hi, My Name is Bruice and im trying to build a commands that teleport's a car model to your place/position, and im super begginer on samp pawno so please help me here is the command:
{anyway im know this is low but dont laugh please just help }
Код HTML:
public OnPlayerCommandText(playerid, cmdtext[])
{
	if (strcmp("/getinf", cmdtext, true, 10) == 0)
	{
        GetPlayerPos(playerid, x, y, z);
        
        CreateVehicle(411, x, y, z, 0, 0, 5);
		SendClientMessage(playerid, COLOR_GREEN, "You have been teleported Infernus to your position");
    return 1;
}
		return 1;
	}
	return 0;
}
Reply
#2

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (!strcmp("/getinf", cmdtext, true))
    {
        new Float:x, Float:y, Float:z;   // You have to define x, y and z as float because they are decimal numbers.
        GetPlayerPos(playerid, x, y, z);
        CreateVehicle(411, x, y, z, 0, 0, 5);
        SendClientMessage(playerid, COLOR_GREEN, "You have been teleported Infernus to your position");
        return 1;
   }   // Also removed an extra brace + return 1 as they were unecessary.
   return 0;
}
Reply
#3

Okay.
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/getinf", cmdtext, true) == 0)
    {
        GetPlayerPos(playerid, x, y, z); // Assuming, they're declared as global variables.
       
        CreateVehicle(411, x, y, z, 0, 0, 5);
        SendClientMessage(playerid, COLOR_GREEN, "You have been teleported Infernus to your position");
        return 1;
    }
    return 0;
}
There was one more extra return 1 and a closed brace. Also, the "/getinf" has lenght 7, not 10.

But since you're beginner, I'd like to say that strcmp is slow for commands. It's better to use ZCMD and it can be used with sscanf for parameters!

Then it would be far easier to do just:
pawn Код:
#include < a_samp >
#include < sscanf2 >
#include < zcmd >

CMD:v( playerid, params[ ] )
{
    new
        modelid,
        Float: XX,
        Float: YY,
        Float: ZZ
    ;
    if( sscanf( params, "i", modelid ) ) return SendClientMessage( playerid, -1, "Usage: /v <modelid>" );
    GetPlayerPos( playerid, XX, YY, ZZ );
    new
        vehicleid
    ;
    vehicleid = CreateVehicle( modelid, XX, YY, ZZ, 0, -1, -1, 60 );
    PutPlayerInVehicle( playerid, vehicleid, 0 );
    return 1;
}
Reply
#4

Thank's for helping, but like i said im new here so, can you make a filterscript in pastebin to show me how its works because i have alot of errors on the complier Thank's ,
Reply
#5

It would be better to post what you have so far and show us the lines and the errors you get. Then we can explain you why it gives them and how to fix them!
Reply
#6

Okay, Here is the error , but by the way im just want when player type /getinf he get an infernus to his currect place/position , example : when im on the LSPD, im typing /getinf im getting an infernus//

[IMG][/IMG]
Reply
#7

Before:
pawn Код:
GetPlayerPos(playerid, x, y, z);
Add:
pawn Код:
new Float: x, Float: y, Float: z;
// we now declared the variables x, y, z so we can use them later.
GetPlayerPos(playerid, x, y, z); // then this line..
About the COLOR_GREEN, you need to define it.

Go at the top, under includes, defines etc..
and add:
pawn Код:
#include <a_samp>
// some other includes and defines

#define COLOR_GREEN 0x00FF00FF

// callbacks here: public blabla..
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)