A bit of help please.
#1

I'm trying to add a command to my script that allows me to spawn vehicles on the server, but it's not working to well.

Код:
{
    if(strcmp(cmd, "/getcar 402", true) == 0)
    CreateVehicle(402, 2109.1763, 1503.0453, 32.2887, 82.2873, 0, 1, 60);
    return 1;
}
This is what happens when try to compile it.

Код:
C:\Users\Jonesy\Desktop\SA-MP scripting\gamemodes\bare.pwn(305) : error 017: undefined symbol "cmd"
C:\Users\Jonesy\Desktop\SA-MP scripting\gamemodes\bare.pwn(310) : warning 225: unreachable code
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.
Reply
#2

pawn Код:
if (strcmp("/getcar 402", cmdtext, true, 10) == 0)
    {
        CreateVehicle(402, 2109.1763, 1503.0453, 32.2887, 82.2873, 0, 1, 60);
        return 1;
    }
Reply
#3

Still having problems, thanks for the quick response though.


Код:
C:\Users\Jonesy\Desktop\SA-MP scripting\gamemodes\bare.pwn(305) : error 017: undefined symbol "cmdtext"
C:\Users\Jonesy\Desktop\SA-MP scripting\gamemodes\bare.pwn(311) : warning 225: unreachable code
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.
Reply
#4

It needs to be under
OnPlayerCommandText
Reply
#5

Thanks for the help guys, for some reason I thought it had to be under OnGameModeInit.
Reply
#6

Do you plant it under OnPlayerCommandText? If you can't understand what TzAkS. and I say, then this is how your code should be written;
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(strcmp("/getcar402", cmdtext, true, 10) == 0)
    {
        CreateVehicle(402, 2109.1763, 1503.0453, 32.2887, 82.2873, 0, 1, 60);

        return 1;
    }
   
    return 0;
}
Reply
#7

Yeah, I've moved it to OnPlayerCommandText now, thanks again for the help.
Reply
#8

Sorry to double post, but I've just thought.. Do I need to add something else to make the car spawn, because on other servers I've seen commands like /spawncar 402 0 0. The "0 0" would set the car to the colour ID. I'm not bothered about changing car colours, but will the car still spawn ok for me, to a random colour?
Reply
#9

Nope, in CreateVehicle there are two values which represent the colours of the vehicle:

Код:
        CreateVehicle(402, 2109.1763, 1503.0453, 32.2887, 82.2873, 0, 1, 60);
Those two value which I have underlined represent the colours, however, if you want to manually select the colour of your vehicle when you are spawning it then you'd have to use something like sscanf, if that's what you wanted.
Reply
#10

What you did was /getcar 402 - which will only spawn CAR ID 402 on BLACK Color ( I guess ) and that only. I will respawn by time and the only way to DESPAWN it is to Restart the server itself and also, it will spawn to the Coordinates you gave on the script not to the players coordinates..
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)