05.11.2010, 21:56
This is Command:
For half the day trying to make a command with x_nr but can not succeed is always some error, so if anyone has a good that my body would help to make this command in x_nr format, I would be very grateful to him, I'm new so I need help.THANKS!!!
Код:
if (strcmp("/carhelp", cmd, true, 10) == 0) { if(IsPlayerConnected(playerid)) { SendClientMessage(playerid, COLOR_GREEN,"_______________________________________"); SendClientMessage(playerid, COLOR_WHITE,"*** CAR HELP *** type the command for more help"); SendClientMessage(playerid, COLOR_GRAD3,"*** CAR *** /park /fixcar /carlock /respraycar"); SendClientMessage(playerid, COLOR_GRAD3,"*** CAR *** /repaintcar /buycar /carsell /exitcar"); #if defined CARSELL SendClientMessage(playerid, COLOR_GRAD3,"*** CAR *** /pcarsell /cancelsell /acceptsell"); #endif } return 1; } else if (strcmp("/park", cmd, true, 10) == 0) { if (IsPlayerInVehicle(playerid,Carlist[playerid][Carid])) { GetVehiclePos(Carlist[playerid][Carid],Carlist[playerid][cX],Carlist[playerid][cY],Carlist[playerid][cZ]); GetVehicleZAngle(Carlist[playerid][Carid],Carlist[playerid][Rotation]); SendClientMessage(playerid, COLOR_GREEN, "Saved car position!"); } else { SendClientMessage(playerid, COLOR_GREY, "That is not your car!"); } return 1; } else if (strcmp("/fixcar", cmd, true, 10) == 0) { if (Carlist[playerid][Typ]!=-1) { if (Carlist[playerid][Status]==0) { new reparatur = Buylist[Carlist[playerid][Typ]][Repair]; if (reparatur <= GetPlayerMoney(playerid)) { Carlist[playerid][Status]=1; Carlist[playerid][Carid]=CreateTunedCar(playerid); GivePlayerMoney(playerid, - reparatur); format(string, 128, "You repaired your car for $%i! It is ready where you parked it.", reparatur); SendClientMessage(playerid, COLOR_RED, string); } else { format(string, 128, "Insufficent money for the repair (need: $%i)!", reparatur); SendClientMessage(playerid, COLOR_LIGHTRED, string); } } else { SendClientMessage(playerid, COLOR_GREY, "Your car does not need a repair!"); } } else { SendClientMessage(playerid, COLOR_GREY, "You do not have a car!"); } return 1; } else if (strcmp("/carlock", cmd, true, 10) == 0) { if (Carlist[playerid][Typ]!=-1) { if (Carlist[playerid][Carid]!=-1) { if (Carlist[playerid][Lock]==0) { Carlist[playerid][Lock]=1; SetVehicleParamsForAll(Carlist[playerid][Carid],0,1); SetVehicleParamsForPlayer(Carlist[playerid][Carid],playerid,0,0); SendClientMessage(playerid, COLOR_RED, "You locked your car for other players!"); } else { Carlist[playerid][Lock]=0; SetVehicleParamsForAll(Carlist[playerid][Carid],0,0); SendClientMessage(playerid, COLOR_RED, "You unlocked your car for other players!"); } } else { SendClientMessage(playerid, COLOR_GREY, "Your car is broken. You have to repair it!"); } } else { SendClientMessage(playerid, COLOR_GREY, "You do not have a car!"); } return 1; } else if (strcmp("/respraycar", cmd, true, 10) == 0) { if (Carlist[playerid][Typ]!=-1) { if (Carlist[playerid][Carid]!=-1) { ChangeVehicleColor(Carlist[playerid][Carid],Carlist[playerid][Color1],Carlist[playerid][Color2]); SendClientMessage(playerid, COLOR_RED, "You resprayed your car!"); } else { SendClientMessage(playerid, COLOR_GREY, "Your car is broken. You have to repair it!"); } } else { SendClientMessage(playerid, COLOR_GREY, "You do not have a car!"); } return 1; } else if (strcmp("/repaintcar", cmd, true, 10) == 0) { if (Carlist[playerid][Typ]!=-1) { if (Carlist[playerid][Carid]!=-1) { if (Carlist[playerid][Paintjob]!=-1) { ChangeVehiclePaintjob(Carlist[playerid][Carid],Carlist[playerid][Paintjob]); SendClientMessage(playerid, COLOR_RED, "You repainted your car!"); } else { SendClientMessage(playerid, COLOR_GREY, "Your car does not have a paintjob yet!"); } } else { SendClientMessage(playerid, COLOR_GREY, "Your car is broken. You have to repair it!"); } } else { SendClientMessage(playerid, COLOR_GREY, "You do not have a car!"); } return 1; } else if (strcmp("/exitcar", cmd, true, 10) == 0) { if (Spectating[playerid][0]!=-1) { TogglePlayerControllable(playerid,1); SetVehicleParamsForAll(Buylist[Spectating[playerid][0]][Carid],0,0); Spectating[playerid][0]=-1; RemovePlayerFromVehicle(playerid); } else { SendClientMessage(playerid, COLOR_GREY, "You are not visiting a demonstration car!"); } return 1; } else if (strcmp("/buycar", cmd, true, 10) == 0) { if (Spectating[playerid][0]!=-1) { if (Carlist[playerid][Typ]==-1) { new price = Buylist[Spectating[playerid][0]][Price]; if (price <= GetPlayerMoney(playerid)) { new autohaus=Buylist[Spectating[playerid][0]][Autohaus]; GivePlayerMoney(playerid, - price); Carlist[playerid][Typ]=Spectating[playerid][0]; Carlist[playerid][cX]=Carspawns[autohaus][cX]; Carlist[playerid][cY]=Carspawns[autohaus][cY]; Carlist[playerid][cZ]=Carspawns[autohaus][cZ]; Carlist[playerid][Rotation]=Carspawns[autohaus][Rotation]; Carlist[playerid][Status]=1; Carlist[playerid][Lock]=0; Carlist[playerid][Carid]=CreateVehicle(Buylist[Spectating[playerid][0]][Modelid],Carlist[playerid][cX],Carlist[playerid][cY],Carlist[playerid][cZ],Carlist[playerid][Rotation],-1,-1,-1); SetVehicleParamsForAll(Buylist[Spectating[playerid][0]][Carid],0,0); TogglePlayerControllable(playerid,1); Spectating[playerid][0]=-1; RemovePlayerFromVehicle(playerid); format(string,128,"Congratulations! You bought yourself a/an $%s for %i!",Buylist[Carlist[playerid][Typ]][Name],price); SendClientMessage(playerid, COLOR_RED, string); SendClientMessage(playerid, COLOR_GREEN, "If your car is broken, type /fixcar to fix it."); SendClientMessage(playerid, COLOR_GREEN, "You can lock/unlock your car for other players with /lock."); SendClientMessage(playerid, COLOR_GREEN, "Look for more commands with /carhelp."); SendClientMessage(playerid, COLOR_YELLOW, "Your car is ready at the release point. Have fun!"); } else { format(string, 128, "Insufficent money to buy the car (need: $%i)!", price); SendClientMessage(playerid, COLOR_LIGHTRED, string); } } else { SendClientMessage(playerid, COLOR_GREY, "You already have a car!"); } } else { SendClientMessage(playerid, COLOR_GREY, "You are not visiting a demonstration car!"); } return 1; } else if (strcmp("/carsell", cmd, true, 10) == 0) { if (Carlist[playerid][Typ]!=-1) { new price = (Buylist[Carlist[playerid][Typ]][Price]/5)*4; if (IsPlayerInVehicle(playerid,Carlist[playerid][Carid])) { RemovePlayerFromVehicle(playerid); } GivePlayerMoney(playerid, price); DestroyVehicle(Carlist[playerid][Carid]); Carlist[playerid][Typ]=-1; Carlist[playerid][cX]=0.0; Carlist[playerid][cY]=0.0; Carlist[playerid][cZ]=0.0; Carlist[playerid][Rotation]=0.0; Carlist[playerid][Status]=0; Carlist[playerid][Lock]=0; Carlist[playerid][Carid]=-1; Carlist[playerid][Color1]=-1; Carlist[playerid][Color2]=-1; Carlist[playerid][mod1]=-1; Carlist[playerid][mod2]=-1; Carlist[playerid][mod3]=-1; Carlist[playerid][mod4]=-1; Carlist[playerid][mod5]=-1; Carlist[playerid][mod6]=-1; Carlist[playerid][mod7]=-1; Carlist[playerid][mod8]=-1; Carlist[playerid][mod9]=-1; Carlist[playerid][mod10]=-1; Carlist[playerid][mod11]=-1; Carlist[playerid][mod12]=-1; Carlist[playerid][mod13]=-1; Carlist[playerid][mod14]=-1; Carlist[playerid][mod15]=-1; Carlist[playerid][mod16]=-1; Carlist[playerid][mod17]=-1; Carlist[playerid][Paintjob]=-1; format(string,128,"You sold successfully your car for $%i!",price); SendClientMessage(playerid, COLOR_RED, string); } else { SendClientMessage(playerid, COLOR_GREY, "You do not have a car!"); } return 1; } #if defined RESETCARS else if (strcmp("/resetcars", cmd, true, 10) == 0) { if(CallRemoteFunction("IsAdmin","i",playerid)) { ResetAutohausSpawns(); } return 1; } #endif #if defined CARSELL else if (strcmp("/pcarsell", cmd, true, 10) == 0) { tmp = strtok(cmdtext, idx); if (!strlen(tmp)) { SendClientMessage(playerid, COLOR_GREY, "Usage: /pcarsell [playerid] [price]"); return 1; } new sellplayerid = ReturnUser(tmp); tmp = strtok(cmdtext, idx); if (!strlen(tmp)) { SendClientMessage(playerid, COLOR_GREY, "Usage: /pcarsell [playerid] [price]"); return 1; } new price = strval(tmp); if (price<0) { SendClientMessage(playerid, COLOR_GREY, "The price has to be bigger than $0."); return 1; } if (Carlist[playerid][Typ]==-1) { SendClientMessage(playerid, COLOR_GREY, "You do not have a car!"); return 1; } if (!IsPlayerConnected(sellplayerid)) { SendClientMessage(playerid, COLOR_GREY, "This player is offline."); return 1; } offerCar[sellplayerid][0]=playerid; offerCar[sellplayerid][1]=price; new sellplayername[MAX_PLAYER_NAME]; GetPlayerName(playerid,playername,sizeof(playername)); GetPlayerName(sellplayerid,sellplayername,sizeof(sellplayername)); format(string,128,"You are offering %s your car for $%i!",sellplayername,price); SendClientMessage(playerid, COLOR_RED, string); SendClientMessage(playerid, COLOR_YELLOW, "Cancel the deal with /cancelsell."); format(string,128,"%s offers his %s for $%i.",playername,Buylist[Carlist[playerid][Typ]][Name],price); SendClientMessage(sellplayerid, COLOR_RED, string); SendClientMessage(sellplayerid, COLOR_YELLOW, "Accept the deal with /acceptsell."); return 1; } else if (strcmp("/cancelsell", cmd, true, 10) == 0) { for (new i=0; i<MAX_PLAYERS; i++) { if (offerCar[i][0]==playerid) { offerCar[i]={-1,0}; SendClientMessage(playerid, COLOR_RED, "You cancelled the deal."); if (IsPlayerConnected(i)) { GetPlayerName(playerid,playername,sizeof(playername)); format(string,128,"%s cancelled the deal.",playername); SendClientMessage(i, COLOR_GREEN, string); } return 1; } } SendClientMessage(playerid, COLOR_GREY, "You are not offering your car!"); return 1; } else if (strcmp("/acceptsell", cmd, true, 10) == 0) { if (offerCar[playerid][0]!=-1) { if (IsPlayerConnected(offerCar[playerid][0])) { if (Carlist[playerid][Typ]==-1) { if (Carlist[offerCar[playerid][0]][Typ]!=-1) { if (GetPlayerMoney(playerid)>=offerCar[playerid][1]) { new sellerid=offerCar[playerid][0]; new price=offerCar[playerid][1]; offerCar[playerid]={-1,0}; GivePlayerMoney(playerid, - price); GivePlayerMoney(sellerid, price); Carlist[playerid][Typ]=Carlist[sellerid][Typ]; Carlist[playerid][cX]=Carlist[sellerid][cX]; Carlist[playerid][cY]=Carlist[sellerid][cY]; Carlist[playerid][cZ]=Carlist[sellerid][cZ]; Carlist[playerid][Rotation]=Carlist[sellerid][Rotation]; Carlist[playerid][Status]=Carlist[sellerid][Status]; Carlist[playerid][Lock]=Carlist[sellerid][Lock]; Carlist[playerid][Carid]=Carlist[sellerid][Carid]; Carlist[playerid][Color1]=Carlist[sellerid][Color1]; Carlist[playerid][Color2]=Carlist[sellerid][Color2]; Carlist[playerid][mod1]=Carlist[sellerid][mod1]; Carlist[playerid][mod2]=Carlist[sellerid][mod2]; Carlist[playerid][mod3]=Carlist[sellerid][mod3]; Carlist[playerid][mod4]=Carlist[sellerid][mod4]; Carlist[playerid][mod5]=Carlist[sellerid][mod5]; Carlist[playerid][mod6]=Carlist[sellerid][mod6]; Carlist[playerid][mod7]=Carlist[sellerid][mod7]; Carlist[playerid][mod8]=Carlist[sellerid][mod8]; Carlist[playerid][mod9]=Carlist[sellerid][mod9]; Carlist[playerid][mod10]=Carlist[sellerid][mod10]; Carlist[playerid][mod11]=Carlist[sellerid][mod11]; Carlist[playerid][mod12]=Carlist[sellerid][mod12]; Carlist[playerid][mod13]=Carlist[sellerid][mod13]; Carlist[playerid][mod14]=Carlist[sellerid][mod14]; Carlist[playerid][mod15]=Carlist[sellerid][mod15]; Carlist[playerid][mod16]=Carlist[sellerid][mod16]; Carlist[playerid][mod17]=Carlist[sellerid][mod17]; Carlist[playerid][Paintjob]=Carlist[sellerid][Paintjob]; Carlist[sellerid][Typ]=-1; Carlist[sellerid][cX]=0.0; Carlist[sellerid][cY]=0.0; Carlist[sellerid][cZ]=0.0; Carlist[sellerid][Rotation]=0.0; Carlist[sellerid][Status]=0; Carlist[sellerid][Lock]=0; Carlist[sellerid][Carid]=-1; Carlist[sellerid][Color1]=-1; Carlist[sellerid][Color2]=-1; Carlist[sellerid][mod1]=-1; Carlist[sellerid][mod2]=-1; Carlist[sellerid][mod3]=-1; Carlist[sellerid][mod4]=-1; Carlist[sellerid][mod5]=-1; Carlist[sellerid][mod6]=-1; Carlist[sellerid][mod7]=-1; Carlist[sellerid][mod8]=-1; Carlist[sellerid][mod9]=-1; Carlist[sellerid][mod10]=-1; Carlist[sellerid][mod11]=-1; Carlist[sellerid][mod12]=-1; Carlist[sellerid][mod13]=-1; Carlist[sellerid][mod14]=-1; Carlist[sellerid][mod15]=-1; Carlist[sellerid][mod16]=-1; Carlist[sellerid][mod17]=-1; Carlist[sellerid][Paintjob]=-1; if (Carlist[playerid][Status]==1) { SetVehicleParamsForAll(Carlist[playerid][Carid],0,Carlist[playerid][Lock]); SetVehicleParamsForPlayer(Carlist[playerid][Carid],playerid,0,0); } format(string,128,"Congratulations! You bought yourself a/an $%s for %i!",Buylist[Carlist[playerid][Typ]][Name],price); SendClientMessage(playerid, COLOR_RED, string); SendClientMessage(playerid, COLOR_GREEN, "If your car is broken, type /fixcar to fix it."); SendClientMessage(playerid, COLOR_GREEN, "You can lock/unlock your car for other players with /lock."); SendClientMessage(playerid, COLOR_GREEN, "Look for more commands with /carhelp."); SendClientMessage(playerid, COLOR_YELLOW, "The car is now yours. Have fun with it!"); GetPlayerName(playerid,playername,sizeof(playername)); format(string,128,"You sold %s your car for $%i!",playername, price); SendClientMessage(sellerid, COLOR_RED, string); } else { format(string, 128, "Insufficent money to buy the car (need: $%i)!", offerCar[playerid][1]); SendClientMessage(playerid, COLOR_GREY, string); } } else { offerCar[playerid]={-1,0}; SendClientMessage(playerid, COLOR_GREY, "The seller does not have a car!."); } } else { SendClientMessage(playerid, COLOR_GREY, "You already have a car!"); } } else { offerCar[playerid]={-1,0}; SendClientMessage(playerid, COLOR_GREY, "The seller is offline."); } } else { SendClientMessage(playerid, COLOR_GREY, "There is no car on offer."); } return 1; }