CosminZEQ Posted December 20, 2018 Report Share Posted December 20, 2018 (edited) cum as punea face cand iti cumperi un nr de tel sa ti de-a 07 in fata ? nu mi dau seama new randphone = 5000 + random(99999) + 5000 ; PlayerInfo[playerid][pPhone] = randphone; Edited December 20, 2018 by CosminZEQ Quote Link to comment Share on other sites More sharing options...
0 Banditul Posted December 20, 2018 Report Share Posted December 20, 2018 Singura solutie e sa scrii tu de mana PlayerInfo[playerid][pPhone][0] = 0; PlayerInfo[playerid][pPhone][1] = 7; Asta o poti pune dupa ce pui randomphone in variabila doar ca nu stiu cat de unic va fi numarul in anumite cazuri(exista o posibilitate) Sau poti pune 07 si dupa sa generezi numarul in spatiile ramase ale array-ului doar ca asta va fi complicat pentru ca va trebui sa asiguri unicitate Quote Link to comment Share on other sites More sharing options...
0 iSkull Posted December 20, 2018 Report Share Posted December 20, 2018 (edited) Ex: new string[15]; format(string, sizeof(string), "07%d", 5000 + random(99999) + 5000); PlayerInfo[playerid][pPhone] = strval(string); Nu am incercat sa vad daca functioneaza 100%, dar ar trebui. Edited December 20, 2018 by iSkull Quote Link to comment Share on other sites More sharing options...
0 Banditul Posted December 20, 2018 Report Share Posted December 20, 2018 (edited) String:0773815 Int:773815 main(){ new string[15]; format(string, sizeof(string), "07%d", 5000 + random(99999) + 5000); printf("String:%s Int:%i", string, strval(string)); } Ca string merge, cand converteste in int o face fara 0 pentru ca 0 pus in fata unui numar e inutil deci e eliminat de strval Edit: De fapt ca idee poti afisa numarul playerului folosind string-ul si cand folosesti comanda de sms/sunat sa fie convertit in int si astfel numarul introdus in comanda si cel convertit din string ala sa fie la fel Edited December 20, 2018 by Banditul Quote Link to comment Share on other sites More sharing options...
0 iSkull Posted December 20, 2018 Report Share Posted December 20, 2018 Acum 3 minute, Banditul a spus: String:0773815 Int:773815 main(){ new string[15]; format(string, sizeof(string), "07%d", 5000 + random(99999) + 5000); printf("String:%s Int:%i", string, strval(string)); } Ca string merge, cand converteste in int o face fara 0 pentru ca 0 pus in fata unui numar e inutil deci e eliminat de strval Daca e ceva, ar trebui sa schimbe din int(de la variabila) in char(string) iar la stats sa modifice cu %s si in comanda sa faca cu strcmp cand va folosi for-ul ca sa-i mearga, e cel mai simplu asa de facut, parerea mea. Quote Link to comment Share on other sites More sharing options...
0 CosminZEQ Posted January 3, 2019 Author Report Share Posted January 3, 2019 va multumesc. Quote Link to comment Share on other sites More sharing options...
0 Lunoxx Posted January 3, 2019 Report Share Posted January 3, 2019 Cel mai simplu e sa lasi numarul asa cum e si sa adaugi doar 07 cand il afisezi, iar la comanda /sms sau /call folosesti specifieri pentru string, daca ai comenzi facute cu ceva procesor de cmd, ("s" in loc de "d" sau "i") si apoi prelucrezi stringul cu strdel pentru a sterge acel "07", dupa care folosesti strval pentru a converti stringul in numarul corect [cel real, fara 07] Quote Servicii scripting calitative: https://www.sa-mp.ro/forums/topic/26143-l-ofer-servicii-scripting-de-calitate/ Contact: Skype: alin.m99 Discord: Lunoxx#1155 Email: [email protected] Facebook: facebook.com/pawnscripts Link to comment Share on other sites More sharing options...
0 Banditul Posted January 3, 2019 Report Share Posted January 3, 2019 Asta imi place la scripting/programare. Exista N moduri de a face un lucru si toate sunt la fel de corecte(mai mult sau mai putin) 1 Quote Link to comment Share on other sites More sharing options...
0 Ph0eniX Posted January 4, 2019 Report Share Posted January 4, 2019 new string[15]; format(string,15,"07%d",5000 + random(99999) + 5000); AccInfo[playerid][NrTel] = strval(string); ... Quote public OnPlayerConnect(playerid) { print("[ERROR] - Unable to establish a connection with the world..."); SendRconCommand("exit"); return 1; } Link to comment Share on other sites More sharing options...
0 Dennis12. Posted January 4, 2019 Report Share Posted January 4, 2019 Acum 11 ore, Banditul a spus: Asta imi place la scripting/programare. Exista N moduri de a face un lucru si toate sunt la fel de corecte(mai mult sau mai putin) Corect, dar sti ce e dureros ? Ca suntem in 2019 si majoritatea, peste 80% nu isi mai scriu codurile singuri, ori le iau dupa gamemode-urile postate pe internet sau "se inspira" de acolo, inspiratia lor inseamna sa ia codul de acolo copy-paste si sa modifice variabilele sa para mai altfel ... si uite asa, toate codurile se aseamana intre ele Quote Link to comment Share on other sites More sharing options...
0 Banditul Posted January 4, 2019 Report Share Posted January 4, 2019 Pai e mai usor. Am vazut multe "gm de la 0" pe care cu usurinta le asemanai cu gm de acum ceva ani. Poate uni nu vor sa invete, pentru ca ce e drept nu e asa usor cum pare. Si incepatorii preiau modele gresite dupa care se ghideaza. O mare parte din scripting atunci cand editezi scriptu altuia e sa citesti codul si sa intelegi ce face. Aici ce e drept trebuie sa studiezi singur elementele de baza si sa stii ce fac(if, switch, acolade(in si out of scope) etc). Si aceste elemente sunt mult mai bine explicate in alte limbaje. Alt lucru care pe mine m-a ajutat a fost sa imi bag nasu in regulile altor limbaje(cum sa denumesti variabile, cum sa numesti functiile, anumite principi ca DRY, KISS, Single Responsibility, clean code etc). Daca chiar vrei sa inveti o faci. Dar cine sa iroseasca timp? (Off-topic constructiv) Quote Link to comment Share on other sites More sharing options...
Question
CosminZEQ
cum as punea face cand iti cumperi un nr de tel sa ti de-a 07 in fata ? nu mi dau seama
new randphone = 5000 + random(99999) + 5000 ;
Edited by CosminZEQPlayerInfo[playerid][pPhone] = randphone;
Link to comment
Share on other sites
10 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.