Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include a_samp
- new
- bool: Salvou[ MAX_PLAYERS char]
- ;
- public OnPlayerConnect(playerid){
- return Salvou{playerid} = !true, !false;
- }
- static stock Carregar(playerid){
- if(Salvou{playerid})
- return SendClientMessage(playerid, -1, "Você não salvou sua posição!");
- static str[100],Nome[30],File: fil;
- strcat(Nome, ".ips");
- fil = fopen(Nome, io_read);
- fread(fil, str);
- SetPlayerPos(playerid, floatstr(getParam(str, 0, '|')), floatstr(getParam(str, 1, '|')), floatstr(getParam(str, 2, '|')));
- return true;
- }
- static stock Salvar(playerid){
- if(Salvou{playerid})
- return SendClientMessage(playerid, -1, "Você já salvou sua posição!");
- static Float: Pos[3], str[100], File: fil, Nome[30];
- strcat(Nome, ".ips");
- GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
- format(str, 100, "%f|%f|%f|", Pos[0], Pos[1], Pos[2]);
- fil = fopen(Nome, io_write);
- fwrite(fil, str);
- fclose(fil);
- Salvou{playerid} = true;
- return true;
- }
- stock getParam(intstring[], parameter, delim){ //
- static
- szStringOut[128],
- Loop_Interator,
- LastWorldSize,
- String_Size,
- Parameters
- ;
- // Setting:
- String_Size = strlen(intstring);
- // Resetting:
- szStringOut[0] = EOS;
- Loop_Interator = 0 ;
- LastWorldSize = 0 ;
- Parameters = 0 ;
- for ( ; Loop_Interator != String_Size; ++Loop_Interator){
- if(intstring[Loop_Interator] == delim){
- if(Parameters == parameter){
- strmid(szStringOut, intstring,(parameter != 0 ? (LastWorldSize + 1) : (LastWorldSize)), Loop_Interator);
- break;
- }
- Parameters ++;
- LastWorldSize = Loop_Interator;
- }
- }
- return szStringOut;
- }
- public OnPlayerCommandText(playerid, cmdtext[]){
- if(!strcmp(cmdtext, "/salvar", true)){
- Salvar(playerid);
- return true;
- }
- if(!strcmp(cmdtext, "/carregar", true)){
- Carregar(playerid);
- return true;
- }
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement