29.11.2009, 05:06
Hi
I have problem with making the following script to work :
(in OnPlayerCommandText)
I wrote comments, so I hope you understand the code. So, after I write /random, instead of moving to random position ( SetPlayerPosFindZ(playerid,float(random(660)),floa t(random(500)),500.0); ) I keep standing in the same place, and after about 1 second, 10 cars spawn, just where I am.
It looks like this (I walked away a bit, so you can see the cars, I spawn "inside" them (because of SetPlayerPos(playerid,xxx,yyy,zzz); ):
I made a few changes in code, but never managed to make it work ... Maybe someone here can deal with this ?
I have problem with making the following script to work :
(in OnPlayerCommandText)
Код:
if(strcmp(cmd, "/random", true) == 0){ new counter = 0; new Float:xxx, Float:yyy, Float:zzz; for(new k=0;k<2000;k++) { DestroyVehicle(k); //Destroy all the cars on the server } for(new s=0;s<10;s=s+1) { SetPlayerPosFindZ(playerid,float(random(660)),float(random(500)),500.0); //Set random position and find Z new Float:xh, Float:yh, Float:zh; GetPlayerPos(playerid,xh,yh,zh); // save coordinates after SetPlayerPosFindZ SetPlayerPosFindZ(playerid, 0,0,500); // move player somewhere else, so the car wouldn't spawn exactly where he is new idveh = CreateVehicle(411,xh,yh,zh,random(360),random(127),random(127),120); // create infernus with random angle and colors GetVehiclePos(idveh, xxx, yyy, zzz); //get the position of car xh = 0.0; yh = 0.0; zh = 0.0; counter = counter + 1; } new msg[48]; format(msg,sizeof(msg),"you made %i cars",counter ); SendClientMessage(playerid,0xFFFFFFFF,msg); SetPlayerPos(playerid,xxx,yyy,zzz); // move player to the location of car (it should be the last one, right?) return 1; }
It looks like this (I walked away a bit, so you can see the cars, I spawn "inside" them (because of SetPlayerPos(playerid,xxx,yyy,zzz); ):
I made a few changes in code, but never managed to make it work ... Maybe someone here can deal with this ?