Help with Strcmp
#1

I dont know know if any one else has asked this already but I have a question. I am having problems with using strcmp I dont really know how to use it because it doesnt seem to be working for me. None of my commands are working. This is what I have.

public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/car", cmdtext, true) == 0)
{
CreateVehicle(506, 0, 0, 0, 0, -1, -1, 0);
return 1;
}
return 0;
}

I am thinking that this should spawn a car. The car is the super gt and Im guessing its supposed to spawn infront of me. If anyone can help me out that would be great. Also if anyone needs more information I can give more if they need it.

Thanks.
Reply
#2

for that, you need to get their position, and spawn it where they're located. CreateVehicle doesn't magicaly know where the player is.
Reply
#3

Quote:
Originally Posted by [B
Vortex ]
for that, you need to get their position, and spawn it where they're located. CreateVehicle doesn't magicaly know where the player is.
is the position in that case no their
Reply
#4

seen as im a noob i think u could do sumate like


public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/car", cmdtext, true) == 0)
{
CreateVehicle(506,(playerpos);

return 1;
}
return 0;

if im wrong ok like i said im a noob
}
Reply
#5

Oh yeah! I think it was playerpos ill try that. thanks
Reply
#6

or u could do it so the player is teled to there own car but im work on the own car part
Reply
#7

Under your command :
pawn Код:
new Float: x ,y ,z;
GetPlayerPos(playerid,x,y,z);
CreateVehicle(506,x+2,y,z);
Thats all i think.
Reply
#8

Cleaner way.
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/car", cmdtext, true) == 0)
    {
    new Float:X, Float:Y, Float:Z, Float:R;
    GetPlayerPos(playerid, X, Y, Z);
    GetPlayerFacingAngle(playerid, R);
    CreateVehicle(506, X, Y, Z, R, -1, -1, 600000);
    return 1;
    }
    return 0;
}
Reply
#9

When i use the command on the server, it doesnt appear right infront of me. It actually appears ontop of a building a little ways away. If you know how to get it to spawn infront the player please tell me.
Reply
#10

See DainyZxZ's Cars filterscript.
pawn Код:
if (strcmp(cmdtext, "/turismo",true)==0)
{
if(IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, 0x33AA33AA, "You are already in a vehicle");
new Float:x,Float:y,Float:z,Float:a;
GetPlayerPos(playerid,x,y,z);
GetPlayerFacingAngle(playerid,a);
CreateVehicle(451,x+1,y+1,z,a,1,1,10000);
return 1;
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)