Re: Show both Name and Steam ID
Just figured out I posted in the wrong forum section.
This thread belong to "Suggestions" forum (used to post help in "Scripting Help").
Anyway, the whole code is so long so I just post the necessary there "name" and "authid" is located.
PHP Code:
public client_PreThink(id) { //make sure player is connected if (is_user_connected(id)) { //display type of block that player is aiming at new ent, body; get_user_aiming(id, ent, body, 320); if (isBlock(ent)) { new blockType = entity_get_int(ent, EV_INT_body); new Name[32]; entity_get_string(ent, EV_SZ_targetname, Name, 31);
new AuthID[32]; entity_get_string(ent, EV_SZ_targetname, AuthID, 31); if(!strcmp(Name, "")) { strcat(Name, "Unknown", 32); }
if(!strcmp(AuthID, "")) { strcat(AuthID, "Unknown", 32); } set_hudmessage(gHudRed, gHudGreen, gHudBlue, gfTextX, gfTextY, gHudEffects, gfHudFxTime, gfHudHoldTime, gfHudFadeInTime, gfHudFadeOutTime, gHudChannel); show_hudmessage(id, "%s^n%s^n%s", gszBlockNames[blockType], Name, AuthID); }
PHP Code:
saveBlocks(id) { //make sure player has access to this command if (get_user_flags(id) & BM_ADMIN_LEVEL) { new file = fopen(gszNewFile, "wt"); new ent = -1; new blockType; new Float:vOrigin[3]; new Float:vAngles[3]; new Float:vStart[3]; new Float:vEnd[3]; new blockCount = 0; new teleCount = 0; new timerCount = 0; new szData[612]; new Float:fMax; new size; new Float:vSizeMax[3]; new Name[32]; new AuthID[32];
while ((ent = find_ent_by_class(ent, gszBlockClassname))) { //get block info blockType = entity_get_int(ent, EV_INT_body); entity_get_vector(ent, EV_VEC_origin, vOrigin); entity_get_vector(ent, EV_VEC_angles, vAngles); entity_get_vector(ent, EV_VEC_maxs, vSizeMax); entity_get_string(ent, EV_SZ_targetname, Name, 31); entity_get_string(ent, EV_SZ_targetname, AuthID, 31);
size = SMALL; fMax = vSizeMax[0] + vSizeMax[1] + vSizeMax[2]; if (fMax > 64.0) size = NORMAL; if (fMax > 128.0) size = LARGE; //format block info and save it to file formatex(szData, 612, "%c %f %f %f %f %f %f %d %s %s^n", gBlockSaveIds[blockType], vOrigin[0], vOrigin[1], vOrigin[2], vAngles[0], vAngles[1], vAngles[2], size, Name, AuthID); fputs(file, szData); //increment block count ++blockCount; }
PHP Code:
loadBlocks(id) { new bool:bAccess = false; //if this function was called on map load, ID is 0 if (id == 0) { bAccess = true; } //make sure user calling this function has access else if (get_user_flags(id) & BM_ADMIN_LEVEL) { bAccess = true; } if (bAccess) { //if map file exists if (file_exists(gszNewFile)) { //if a player is loading then first delete all the old blocks, teleports and timers if (id > 0 && id <= 32) { deleteAllBlocks(id, false); deleteAllTeleports(id, false); deleteAllTimers(id, false); } new szData[612]; new szType[2]; new sz1[16], sz2[16], sz3[16], sz4[16], sz5[16], sz6[16], sz7[16], szName[32], szAuthID[32]; new Float:vVec1[3]; new Float:vVec2[3]; new axis; new size; new f = fopen(gszNewFile, "rt"); new blockCount = 0; new teleCount = 0; new timerCount = 0; new bool:bTimerStart = true; new Float:vTimerOrigin[3]; new Float:vTimerAngles[3]; new ent; //iterate through all the lines in the file while (!feof(f)) { szType = ""; fgets(f, szData, 612); parse(szData, szType, 1, sz1, 16, sz2, 16, sz3, 16, sz4, 16, sz5, 16, sz6, 16, sz7, 16, szName, 32, szAuthID, 32); vVec1[0] = str_to_float(sz1); vVec1[1] = str_to_float(sz2); vVec1[2] = str_to_float(sz3); vVec2[0] = str_to_float(sz4); vVec2[1] = str_to_float(sz5); vVec2[2] = str_to_float(sz6); size = str_to_num(sz7); if (strlen(szType) > 0) { //if type is not a teleport if (szType[0] != gTeleportSaveId) { //set axis orientation depending on block angles if (vVec2[0] == 90.0 && vVec2[1] == 0.0 && vVec2[2] == 0.0) { axis = X; } else if (vVec2[0] == 90.0 && vVec2[1] == 0.0 && vVec2[2] == 90.0) { axis = Y; } else { axis = Z; } //increment block counter ++blockCount; } //create block or teleport depending on type switch (szType[0]) { case 'A': ent = createBlock(0, BM_PLATFORM, vVec1, axis, size); //...and so on.
case gTeleportSaveId: { createTeleport(0, TELEPORT_START, vVec1); createTeleport(0, TELEPORT_END, vVec2); //increment teleport count ++teleCount; } case gTimerSaveId: { //is this the first timer info retrieved from file? if (bTimerStart) { //store start timer info vTimerOrigin[0] = vVec1[0]; vTimerOrigin[1] = vVec1[1]; vTimerOrigin[2] = vVec1[2]; vTimerAngles[0] = vVec2[0]; vTimerAngles[1] = vVec2[1]; vTimerAngles[2] = vVec2[2]; //the next timer to come along is the end of the timer bTimerStart = false; } else { //create the start of timer createTimer(0, TIMER_START, vTimerOrigin, vTimerAngles); //create the end of the timer createTimer(0, TIMER_END, vVec1, vVec2); //if another timer comes along then it'll be the start again bTimerStart = true; //increment timer count ++timerCount; } } default: { log_amx("%sInvalid block type: %c in: %s", gszPrefix, szType[0], gszFile); //decrement block counter because a block was not created --blockCount; } } if (is_valid_ent(ent)) { // if its there if(strcmp(szName, "")) { entity_set_string(ent, EV_SZ_targetname, szName); }
if(strcmp(szAuthID, "")) { entity_set_string(ent, EV_SZ_targetname, szAuthID); } } } }
|