SA-MP Forums Archive
Help||Command Text - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Help||Command Text (/showthread.php?tid=462754)



Help||Command Text - wakeuptomer - 08.09.2013

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;
}



Re: Help||Command Text - Dragonsaurus - 08.09.2013

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;
}



Re: Help||Command Text - Konstantinos - 08.09.2013

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;
}



Re: Help||Command Text - wakeuptomer - 08.09.2013

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 ,


Re: Help||Command Text - Konstantinos - 08.09.2013

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!


Re: Help||Command Text - wakeuptomer - 08.09.2013

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]


Re: Help||Command Text - Konstantinos - 08.09.2013

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..