Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <filemanager>
- /*** Colors ***/
- #define Green 0x33FF33FF
- #define Green_dark 0x33BB33FF
- #define White 0xFFFFFFFF
- #define Gray 0x999999FF
- #define PwnDir "PowerPawn"
- #define PwnFile "PowerPawn/positions.pwn"
- public OnFilterScriptInit()
- {
- if(!dir_exists(PwnDir))
- {
- ConsoleWrite("Folder \"PowerPawn\" created");
- dir_create(PwnDir);
- }
- if(!file_exists(PwnFile))
- {
- ConsoleWrite("File\"PowerPawn/positions.pwn\" created");
- file_create(PwnFile);
- }
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- new cmd[256], idx;
- cmd = strtok(cmdtext, idx);
- if(strcmp(cmd, "/static", true) == 0)
- {
- if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, White, "You're not admin!");
- new func[256];
- func = strtok(cmdtext, idx);
- if(!strlen(func))
- {
- SendClientMessage(playerid, White, "Usage: /static [function]");
- SendClientMessage(playerid, Gray, "Functions");
- SendClientMessage(playerid, Gray, "Teleport, Class, Vehicle, Object, 3DText, Pickup, Checkpoint");
- return 1;
- }
- if(strcmp(func, "Teleport", true) == 0)
- {
- new comm[256];
- comm = strtok(cmdtext, idx);
- if(!strlen(comm)) return SendClientMessage(playerid, White, "Usage: /static teleport [comment]");
- new str[200];
- new Float:X, Float:Y, Float:Z, Float:A;
- GetPlayerPos(playerid, X, Y, Z);
- GetPlayerFacingAngle(playerid, A);
- format(str, sizeof(str), "SetPlayerPos(playerid, %f, %f, %f), SetPlayerFacingAngle(playerid, %f);", X, Y, Z, A);
- Save(str, comm);
- SendClientMessage(playerid, Green_dark, "Teleport added to file.");
- return 1;
- }
- if(strcmp(func, "Class", true) == 0)
- {
- new comm[256];
- comm = strtok(cmdtext, idx);
- if(!strlen(comm)) return SendClientMessage(playerid, White, "Usage: /static class [comment]");
- new str[200];
- new Float:X, Float:Y, Float:Z, Float:A;
- GetPlayerPos(playerid, X, Y, Z);
- GetPlayerFacingAngle(playerid, A);
- format(str, sizeof(str), "AddPlayerClass(%i, %f, %f, %f, %f, 0, 0, 0, 0, 0, 0);", GetPlayerSkin(playerid), X, Y, Z, A);
- Save(str, comm);
- SendClientMessage(playerid, Green_dark, "Class added to file.");
- return 1;
- }
- if(strcmp(func, "Vehicle", true) == 0)
- {
- new c1[256], c2[256], comm[256];
- c1 = strtok(cmdtext, idx);
- c2 = strtok(cmdtext, idx);
- comm = strtok(cmdtext, idx);
- if(!IsPlayerInAnyVehicle(playerid)) SendClientMessage(playerid, White, "You need to be in vehicle!");
- if(!strlen(c1) || !strlen(c2) || !strlen(comm)) return SendClientMessage(playerid, White, "Usage: /static vehicle [color1] [color2] [comment]");
- new str[200];
- new car = GetPlayerVehicleID(playerid);
- new Float:X, Float:Y, Float:Z, Float:A;
- GetVehiclePos(car, X, Y, Z);
- GetVehicleZAngle(car, A);
- format(str, sizeof(str), "AddStaticVehicle(%i, %f, %f, %f, %f, %i, %i);", GetVehicleModel(car), X, Y, Z, A, strval(c1), strval(c2));
- Save(str, comm);
- SendClientMessage(playerid, Green_dark, "Vehicle added to file.");
- return 1;
- }
- if(strcmp(func, "Object", true) == 0)
- {
- new ob[256], comm[256];
- ob = strtok(cmdtext, idx);
- comm = strtok(cmdtext, idx);
- if(!strlen(ob) || !strlen(comm)) return SendClientMessage(playerid, White, "Usage: /static object [objectmodel] [comment]");
- new str[200];
- new Float:X, Float:Y, Float:Z;
- GetPlayerPos(playerid, X, Y, Z);
- format(str, sizeof(str), "CreateObject(%i, %f, %f, %f, 0, 0, 0);", strval(ob), X, Y, Z);
- Save(str, comm);
- SendClientMessage(playerid, Green_dark, "Object added to file.");
- return 1;
- }
- if(strcmp(func, "3DText", true) == 0)
- {
- new comm[256];
- comm = strtok(cmdtext, idx);
- if(!strlen(comm)) return SendClientMessage(playerid, White, "Usage: /static 3dtext [comment]");
- new str[200];
- new Float:X, Float:Y, Float:Z;
- GetPlayerPos(playerid, X, Y, Z);
- format(str, sizeof(str), "Create3DTextLabel(\">>TEXT<<\", 0xFFFFFFFF, %f, %f, %f, 100.0, 0, 0);", X, Y, Z);
- Save(str, comm);
- SendClientMessage(playerid, Green_dark, "3D Text added to file.");
- return 1;
- }
- if(strcmp(func, "pickup", true) == 0)
- {
- new pid[256], pty[256], comm[256];
- pid = strtok(cmdtext, idx);
- pty = strtok(cmdtext, idx);
- comm = strtok(cmdtext, idx);
- if(!strlen(pid) || !strlen(pty) || !strlen(comm)) return SendClientMessage(playerid, White, "Usage: /static pickup [pickupmodel] [pickuptype] [comment]");
- new str[200];
- new Float:X, Float:Y, Float:Z;
- GetPlayerPos(playerid, X, Y, Z);
- format(str, sizeof(str), "CreatePickup(%i, %i, %f, %f, %f, 0);", strval(pid), strval(pty), X, Y, Z);
- Save(str, comm);
- SendClientMessage(playerid, Green_dark, "Pickup added to file.");
- return 1;
- }
- if(strcmp(func, "Checkpoint", true) == 0)
- {
- new comm[256];
- comm = strtok(cmdtext, idx);
- if(!strlen(comm)) return SendClientMessage(playerid, White, "Usage: /static checkpoint [comment]");
- new str[200];
- new Float:X, Float:Y, Float:Z;
- GetPlayerPos(playerid, X, Y, Z);
- format(str, sizeof(str), "SetPlayerCheckpoint(playerid, %f, %f, %f, 5);", X, Y, Z);
- Save(str, comm);
- SendClientMessage(playerid, Green_dark, "Checkpoint added to file.");
- return 1;
- }
- return SendClientMessage(playerid, White, "Wrong function!");
- }
- return 0;
- }
- ConsoleWrite(const string[])
- {
- new str[128];
- format(str, sizeof(str), "[PowerPawn::Partner] %s", string);
- print(str);
- return 1;
- }
- Save(const string[], const comment[])
- {
- new str[200];
- format(str, sizeof(str), "%s // %s\n", string, comment);
- file_write(PwnFile, str);
- return 1;
- }
- strtok(const string[], &index)
- {
- new length = strlen(string);
- while ((index < length) && (string[index] <= ' '))
- {
- index++;
- }
- new offset = index;
- new result[20];
- while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
- {
- result[index - offset] = string[index];
- index++;
- }
- result[index - offset] = EOS;
- return result;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement