PDA

View Full Version : cmd error


hardiksingh5
30/03/2015, 04:37 AM
if(strcmp(cmd, "/deleteairline", true) == 0)
{
if(!strcmp(PlayerName(playerid), "Pacoz"))
{
new airlineid;
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_ERROR, "Syntax: /deleteairline (airline id)");
return 1;
}
airlineid = strvalEx(tmp);
if(airlineid < 0)
{
SendClientMessage(playerid, COLOR_ERROR, "Airline ID must be over 0.");
return 1;
}
new msg[156];
format(msg,sizeof(msg),"Administrator %s(%d) has deleted airline ID %d (%s)",PlayerName(playerid),playerid,airlineid,AInfo[airlineid][aName]);
SendAdminMessage(COLOR_ADMIN,msg);
new query[750];
AdminLog(playerid, "/deleteairline", "Deleted Airline", "Airline");
format(query,sizeof(query),"UPDATE airlines SET Name='Empty',Owner='None',Flights='0',Payrate='50' ,Balance='0',Rank1='Default',Rank2='Default',Rank3 ='Default',Rank4='Default',Rank5='Default',Rank6=' Default',totalearnt='0',totalpaid='0',fleetslots=' 5',fleettotal='0',uniform='1',pos1='0',pos2='0',po s3='0',pos4='0',motd='None',motdsetby='None',invme mbers='6',rmvmembers='6',prmmembers='6',prkfleet=' 6',clrfleet='6',bnkperm='6',rspfleet='6',distance= '0' WHERE ID = '%d'", airlineid);
mysql_reconnect();
mysql_query(query);
for(new i; i<MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(PInfo[i][Airline] == airlineid)
{
PInfo[i][Airline] = 0;
SendClientMessage(i, COLOR_ERROR, "An administrator has deleted the airline you were in. You have been kicked out.");
}
}
}
format(query,sizeof(query),"UPDATE users SET earntforairline='0',airline='0',airlinerank='0',ai rlineflights='0' WHERE airline = '%d'", airlineid);
mysql_reconnect();
mysql_query(query);
format(query,sizeof(query),"DELETE FROM avehicles WHERE Airline = '%d'", airlineid);
mysql_query(query);
return 1;
}
else
{
SendClientMessage(playerid, COLOR_ERROR, "You are not a developer !");
return 1;
}
}
if(strcmp(cmd, "/reloadairline", true) == 0)
{
if(PInfo[playerid][AdminLevel] < 5) { SendClientMessage(playerid, COLOR_ERROR, "You are not an administrator !"); return 1; }
new airlineid;
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_ERROR, "Syntax: /reloadairline (airline id)");
return 1;
}
airlineid = strvalEx(tmp);
if(airlineid < 0 || airlineid > MAX_AIRLINES)
{
SendClientMessage(playerid, COLOR_ERROR, "Airline ID's: 1-5.");
return 1;
}
new msg[128];
format(msg,sizeof(msg),"Administrator %s(%d) has reloaded airline %s(%d)",PlayerName(playerid), playerid, AInfo[airlineid][aName], airlineid);
SendAdminMessage(COLOR_ADMIN, msg);
LoadAirline(airlineid);
AdminLog(playerid, "/reloadairline", "Reloaded Airline", "Airline");
return 1;
}
if(strcmp(cmd, "/movehouse", true) == 0)
{
if(PInfo[playerid][AdminLevel] < 5 ) { SendClientMessage(playerid, COLOR_ERROR, "You are not an administrator !"); return 1; }
new airlineid;
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_ERROR, "Syntax: /movehouse (house id)");
return 1;
}
airlineid = strvalEx(tmp);
new Float:X, Float:Y, Float:Z;
GetPlayerPos(playerid, X,Y,Z);
new query[200];
format(query,sizeof(query),"UPDATE houses SET eX='%f', eY='%f', eZ='%f' WHERE HouseID = '%d'",X,Y,Z,airlineid);
mysql_reconnect();
mysql_query(query);
new msg[128];
format(msg,sizeof(msg),"Administrator %s(%d) has moved house ID %d",PlayerName(playerid), playerid, airlineid);
SendAdminMessage(COLOR_ADMIN, msg);
AdminLog(playerid, "/movehouse", "Moved House", "House");
ReloadHouse(airlineid);
return 1;
}
if(strcmp(cmd, "/deletemapicon", true) == 0)
{
if(PInfo[playerid][AdminLevel] < 5) { SendClientMessage(playerid, COLOR_ERROR, "You are not an administrator!"); return 1; }
new mapid;
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_ERROR, "Syntax: /deletemapicon (Map icon ID)");
return 1;
}
mapid = strvalEx(tmp);
new query[200];
format(query,sizeof(query),"DELETE FROM mapicons WHERE ID = '%d' LIMIT 1", mapid);
mysql_query(query);
DestroyDynamicMapIcon(MapIconData[mapid][MapIcon]);
SendClientMessage(playerid, COLOR_WHITE, "You have deleted the map icon successfully.");
return 1;
}
if(strcmp(cmd, "/addmapicon", true) == 0)
{
if(PInfo[playerid][AdminLevel] < 5) { SendClientMessage(playerid, COLOR_ERROR, "You are not an administrator!"); return 1; }
new iconid;
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_ERROR, "Syntax: /addmapicon (SA:MP Icon ID) - Uses your player position!");
return 1;
}
iconid = strvalEx(tmp);
new Float:pX, Float:pY, Float:pZ;
GetPlayerPos(playerid, pX, pY, pZ);
new query[400];
format(query,sizeof(query),"INSERT INTO mapicons (IconID, IconX, IconY, IconZ) VALUES ('%d', '%f', '%f', '%f')", iconid, pX, pY, pZ);
mysql_query(query);
format(query,sizeof(query),"SELECT `ID` FROM mapicons WHERE IconX='%f'",pX);
mysql_query(query);
mysql_store_result();
new nMapID = mysql_fetch_int();
mysql_free_result();
format(query,sizeof(query),"Added icon successfully. [ID:%d]", nMapID);
SendClientMessage(playerid, COLOR_WHITE, query);
CreateDynamicMapIcon(pX, pY, pZ, iconid, 0);
return 1;
}
if(strcmp(cmd, "/deletehouse", true) == 0)
{
if(strcmp(PlayerName(playerid), "Pacoz"))
{
SendClientMessage(playerid, COLOR_ERROR, "You are not a Developer !");
return 1;
}
new airlineid;
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_ERROR, "Syntax: /deletehouse (house id)");
return 1;
}
airlineid = strvalEx(tmp);
new query[250];
format(query,sizeof(query),"DELETE FROM houses WHERE HouseID = '%d'", airlineid);
mysql_reconnect();
mysql_query(query);
DestroyDynamicMapIcon(HInfo[airlineid][hMapIcon]);
Delete3DTextLabel(HInfo[airlineid][hHouseText]);
DestroyPickup(HInfo[airlineid][hPickupID]);
new msg[128];
format(msg,sizeof(msg),"Administrator %s(%d) has deleted house ID %d",PlayerName(playerid), playerid, airlineid);
SendAdminMessage(COLOR_ADMIN, msg);
AdminLog(playerid, "/deletehouse", "Deleted House", "House");
return 1;
}
if(strcmp(cmd, "/addplayervehicle", true) == 0)
{
if(!strcmp(PlayerName(playerid), "Pacoz"))
{
if(IsPlayerInAnyVehicle(playerid))
{
new price;
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_ERROR, "Syntax: /addplayervehicle (price)");
return 1;
}
price = strvalEx(tmp);
if(price < 100000) { SendClientMessage(playerid, COLOR_ERROR, "Too cheap!"); return 1; }
AddVehicle(playerid, price);
AdminLog(playerid, "/addplayervehicle", "Created Player Vehicle", "Vehicle");
return 1;
}
else
{
SendClientMessage(playerid, COLOR_ERROR, "You are not in a vehicle!");
return 1;
}
}
else
{
SendClientMessage(playerid, COLOR_ERROR, "Developer's only !");
return 1;
}
}
if(strcmp(cmd, "/reloadhouse", true) == 0)
{
if(PInfo[playerid][AdminLevel] < 5) { SendClientMessage(playerid, COLOR_ERROR, "You are not an administrator !"); return 1; }
new airlineid;
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_ERROR, "Syntax: /reloadhouse (house id)");
return 1;
}
airlineid = strvalEx(tmp);
if(airlineid < 0 || airlineid > MAX_HOUSES || airlineid == 1)
{
SendClientMessage(playerid, COLOR_ERROR, "Valid house ID's are 2-500.");
return 1;
}
new msg[128];
format(msg,sizeof(msg),"Administrator %s(%d) has reloaded house ID %d",PlayerName(playerid), playerid, airlineid);
SendAdminMessage(COLOR_ADMIN, msg);
ReloadHouse(airlineid);
AdminLog(playerid, "/reloadhouse", "Reloaded House", "House");
return 1;
}
if(strcmp(cmd, "/veh", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if(PInfo[playerid][AdminLevel] < 4) { SendClientMessage(playerid, COLOR_ERROR, "You are not an administrator !"); return 1; }
new moneys;
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_SECURITY, "Syntax: /veh [Vehicle Model]");
return 1;
}
moneys = strvalEx(tmp);
if(moneys < 400 || moneys > 611)
{
SendClientMessage(playerid, COLOR_ERROR, "Cannot go over 611 or under 400 !");
return 1;
}
new Float:X, Float:Y, Float:Z, Float:A;
GetPlayerPos(playerid, X,Y,Z);
GetPlayerFacingAngle(playerid,A);
new carid = CreateVehicle(moneys, X,Y,Z,A, -1, -1, -1);
gDestroyVehicle[carid] = 1;
PutPlayerInVehicle(playerid,carid,0);
LinkVehicleToInterior(carid,GetPlayerInterior(play erid));
PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
vfuel[carid] = 100;
VInfo[carid][ID] = 0;
aVInfo[carid][ID] = 0;
aVInfo[carid][AID] = 0;
AdminLog(playerid, "/veh", "Spawned Vehicle", "Vehicle");
for(new i = 0; i < sizeof(CreatedCars); i++)
{
if(CreatedCars[i] == INVALID_VEHICLE_ID)
{
CreatedCars[i] = carid;
break;
}
}
// fuel[carid] = 100;
}
return 1;
}
if(strcmp(cmd, "/destroyvehicles", true) == 0)
{
if(PInfo[playerid][AdminLevel] > 3)
{
new vehcount = 0;
for(new i = 0; i < sizeof(CreatedCars); i++)
{
if(CreatedCars[i] != INVALID_VEHICLE_ID)
{
vehcount++;
gDestroyVehicle[CreatedCars[i]] = 1;
SetVehicleToRespawn(CreatedCars[i]);
CreatedCars[i] = INVALID_VEHICLE_ID;
}
}
new msg[128];
format(msg,sizeof(msg),"Administrator {1B8AE4}%s(%d) {FFFFFF}has de-spawned all admin-spawned vehicles", PlayerName(playerid),playerid);
SendClientMessageToAll(COLOR_WHITE, msg);
AdminLog(playerid, "/destroyvehicles", "Destroyed Vehicles", "Vehicle");
return 1;
}
return 1;
}
if(strcmp(cmd, "/giveveh", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if(PInfo[playerid][AdminLevel] < 4) { SendClientMessage(playerid, COLOR_ERROR, "You are not an administrator !"); return 1;}
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_SECURITY, "Syntax: /giveveh (playername/id) (Vehicle Model)");
return 1;
}
new playa;
new money;
playa = ReturnUser(tmp);
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_SECURITY, "Syntax: /giveveh (playername/id) (Vehicle Model)");
return 1;
}
money = strvalEx(tmp);
if(money < 400 || money > 610)
{
SendClientMessage(playerid, COLOR_ERROR, "Cannot go over 611 or under 400 !");
return 1;
}
new Float:X, Float:Y, Float:Z, Float:A;
GetPlayerPos(playa, X,Y,Z);
GetPlayerFacingAngle(playa,A);
new carid = CreateVehicle(money, X,Y,Z,A, -1, -1, -1);
gDestroyVehicle[carid] = 1;
PutPlayerInVehicle(playa,carid,0);
LinkVehicleToInterior(carid,GetPlayerInterior(play erid));
PlayerPlaySound(playa, 1052, 0.0, 0.0, 0.0);
vfuel[carid] = 100;
VInfo[carid][ID] = 0;
aVInfo[carid][ID] = 0;
aVInfo[carid][AID] = 0;
AdminLog(playerid, "/giveveh", "Given Vehicle", PlayerName(playa));
for(new i = 0; i < sizeof(CreatedCars); i++)
{
if(CreatedCars[i] == INVALID_VEHICLE_ID)
{
CreatedCars[i] = carid;
break;
}
}
//fuel[carid] = 100;
}
return 1;
}
if(strcmp(cmd, "/addvehicle", true) == 0)
{
if(IsPlayerInAnyVehicle(playerid))
{
if(PInfo[playerid][AdminLevel] > 4)
{
new length = strlen(cmdtext);
while ((idx < length) && (cmdtext[idx] <= ' '))
{
idx++;
}
new offset = idx;
new result[128];
while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
{
result[idx - offset] = cmdtext[idx];
idx++;
}
if(!strlen(result))
{
SendClientMessage(playerid, COLOR_SECURITY, "Syntax: /addvehicle [e.g: Shamal, LS Airport 2.]");
return 1;
}
result[idx - offset] = EOS;
new VC1 = -1;
new VC2 = -1;
if(PInfo[playerid][AdminLevel] < 2) { SendClientMessage(playerid, COLOR_ERROR, "You are not an administrator !"); return 1;}
new Float: VX, Float: VY, Float: VZ, Float: VA, dModel, Msg[64];
GetPlayerPos(playerid, VX, VY, VZ);
GetVehicleZAngle(GetPlayerVehicleID(playerid), VA);
dModel = GetVehicleModel(GetPlayerVehicleID(playerid));
mysql_reconnect();
new Query[500];
format(Query, sizeof(Query), "INSERT INTO `vehicles` (VehicleModel, VehicleX, VehicleY, VehicleZ, VehicleAngle, VehicleColor1, VehicleColor2) VALUES(%d, %f, %f, %f, %f, %d, %d)",
dModel, VX, VY, VZ, VA, VC1, VC2);

mysql_query(Query);
mysql_free_result();
format(Msg, sizeof(Msg), "Vehicle added to database - Model: %d",dModel);
SendClientMessage(playerid, COLOR_YELLOW, Msg);
AdminLog(playerid, "/addvehicle", "Added Vehicle to Server", "Vehicle");
return 1;
}
}
else
{
SendClientMessage(playerid, COLOR_ERROR, "You are not in a vehicle !");
return 1;
}
}
if(strcmp(cmd, "/afklist", true) == 0)
{
SendClientMessage(playerid, COLOR_GREEN, "{FFFFFF}覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧 ");
SendClientMessage(playerid, COLOR_BLUE, "Current members which are AFK:");
for(new i; i<MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i) && AFKPLAYER[i] == 1)
{
format(string, sizeof(string), "{FFFFFF}%s(%d): {1B8AE4}[%s]",PlayerName(i),i,AFKREASON[i]);
SendClientMessage(playerid, COLOR_WHITE, string);
}
}
SendClientMessage(playerid, COLOR_GREEN, "{FFFFFF}覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧覧 ");
return 1;
}



can somebody give me a code of making airlines in game instead of making from database

[ABK]Antonio
30/03/2015, 04:45 AM
Can you use the [pawn] tag so we can see the indentations lol

Runn3R
30/03/2015, 09:49 AM
Why are you still using strcmp if there is some faster command processors like ZCMD or Y_CMD...

CalvinC
30/03/2015, 10:02 AM
Do we have to tell you this each time you post?
Script Requests - If you are requesting a script be made for you, rather than help with your coding, post in the Looking for scripters/helpers? Post here! Thread.
http://forum.sa-mp.com/showthread.php?t=447813