PDA

View Full Version : A bit of help please.


JonesyFoCoTDM
05/04/2012, 09:03 AM
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 (c) 1997-2006, ITB CompuPhase


1 Error.

Ironboy
05/04/2012, 09:04 AM
if (strcmp("/getcar 402", cmdtext, true, 10) == 0)
{
CreateVehicle(402, 2109.1763, 1503.0453, 32.2887, 82.2873, 0, 1, 60);
return 1;
}

JonesyFoCoTDM
05/04/2012, 09:08 AM
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 (c) 1997-2006, ITB CompuPhase


1 Error.

TzAkS.
05/04/2012, 09:16 AM
It needs to be under
OnPlayerCommandText

JonesyFoCoTDM
05/04/2012, 09:21 AM
Thanks for the help guys, for some reason I thought it had to be under OnGameModeInit.

Toreno
05/04/2012, 09:24 AM
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;

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

JonesyFoCoTDM
05/04/2012, 09:30 AM
Yeah, I've moved it to OnPlayerCommandText now, thanks again for the help.

JonesyFoCoTDM
05/04/2012, 11:13 AM
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?

Mosslah
05/04/2012, 11:26 AM
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.

Aira
05/04/2012, 11:26 AM
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..

JonesyFoCoTDM
05/04/2012, 11:41 AM
I'm new to scripting as you can probably tell. Thanks for pointing out about the colours. About the co-ordinates, I was under the impression that those co-ordinates spawn the vehicle in-front of you, or am I completely wrong?

Aira
05/04/2012, 11:48 AM
On my Single Player Features Filterscirpt ( on my Signature below ) it will help you with your problem..
Look for /ohdude then understand how its done.

Note: That will help you with the "Spawning Location Near your Player" only, not with the "selecting of Vehicle ID and Color ID's"